Alex writes "Hello, would like to seek your advice on the following issue:I have a table like such: TIMESTAMP UNIT_ID COMPONENT_ID OPERATIONS RUNTIME{timestamp} Unit1 Comp1 5 700{timestamp} Unit1 Comp2 6 300{timestamp} Unit2 Comp1 7 1700{timestamp} Unit2 Comp2 8 2700{timestamp+1} Unit1 Comp1 9 6200{timestamp+1} Unit1 Comp2 4 100{timestamp+1} Unit2 Comp1 3 2300{timestamp+1} Unit2 Comp2 5 1800 What I wish to return is:Sum of RUNTIME for all COMPONENT_ID=Comp1 as SUM1Sum of RUNTIME for all COMPONENT_ID=Comp2 as SUM2What I can do:At present I only know of how to return one of the above. I have tried declaring integers to hold summations, but I couldn't get this to work.What I am seeking:The general idea of what I want is as follows... SELECT totalC1, totalC2 from(SELECT SUM(runtime) as totalC1 where COMPONENT_ID=Comp1JOINSELECT SUM(runtime) as totalC2 where COMPONENT_ID=Comp2)
RETURNING:TOTALC1 TOTALC210900 4900
Oh, and I don't want to have to do this is a stored procedure - but rather a direct SQL query... ideally ;o}Hope you can help!"