Hi -

I'm running 4.0.18, so I can't use subqueries.  I need to run a query to get the sum 
of costs from multiple tables for a given master table.  

What I have right now which is clearly not going to work is:

SELECT conveyor.serial, SUM(conveyorsupport.cost), SUM(conveyoraccessories.cost) from 
(conveyor LEFT JOIN conveyorsupport on conveyor.serial = conveyorsupport.serial) LEFT 
JOIN conveyoraccessories on conveyor.serial = conveyoraccessories.serial

This will return a product for the sum of conveyor accessories (however many supports 
there are times the sum of accessories).  

I believe if I was running a later version, I could use a subqueries, or if it was 
supported, correlated sub queries in the from statement.

Thanks,

Roger


Sample Data (other fields exist but I believe are superfluous)

Conveyor:

Serial
100000
100001

Support
Serial        Cost
10000        100
10000        150
10001        200
10001        250

Accessory
Serial        Cost
10000        50
10000        75
10001        100
10001        200

Desired Result
Serial        SupportCost    AccessoryCost
100000        250                125
100001        450                300

Reply via email to