× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I would probably use Common Table Expressions to summarize the labor
files, then join the summary data to your job master...

With
lPlan (jobid, jobhours) as
( Select jobid, sum(jobhours)
From laborPlan
Group by jobid ),

lExec (jobid, jobhours) as
( Select jobid, sum(jobhours)
From laborExec
Group by jobid )

Select master_job.*, lPlan.jobhours, lExec.jobhours
From master_job
left outer join
lPlan on (master_job.jobid = lPlan.jobid)
left outer join
lExec on (master_job.jobid = lExec.jobid)


hth,
-Eric DeLong


-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Adam West
Sent: Thursday, May 14, 2009 10:51 AM
To: Midrange Systems Technical Discussion
Subject: SQL with several tables

Hi everybody,

I have 3 tables, one with the master_job, other is with Labor planed and
other with labor executed - those labors could have many lines in it.

I need to create a report that shows for each job the total amout of
planed labor and the total amount of executed labor.

Because the labor tables are linked to the master_job, when i create the
report the result is duplicating the lines.

Anyone knows how to extract just the totals for each job with the total
planed and total executed ?






As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.