× 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.



If you can use SQL, this might work:

Select mj.job, sum(coalesce(lp.hours,0)), sum(coalesce(le.hours,0))
From master_job mj
Left outer join labor_plan lp on (mj.job=lp.job)
Left outer join labor_exec le on (mj.job=le.job)

If you get duplicates or off-totals from this, try:

With letemp as (select job, sum(hours) from labor_exec),
Lptemp as (select job, sum(hours) from labor_plan)
Select mj.job, sum(coalesce(lp.hours,0)), sum(coalesce(le.hours,0))
From master_job mj
Left outer join lptemp lp on (mj.job=lp.job)
Left outer join letemp le on (mj.job=le.job)

HTH,
Loyd

-----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.