meridian99
MIS
I would like to create a sql that provides a single row subquery to search 2 tables. 1 being a master linked to a details which contains 1/more transaction records for each master.
for each unique piece of equipment, total up all its costs for a given year as in
pump12345, main motor pump, $25,700.00
Something like...
select equipment_no, equipment_desc
from equipment_table
where equipment_status = 'ACTIVE' and year = 2004 and
total_cost = (select sum(costs) from equip_data);
equip_no is in both tables with the costs in the detail
table.
Not sure if I can do the SUM() and have it passed back to the main query for reporting?
for each unique piece of equipment, total up all its costs for a given year as in
pump12345, main motor pump, $25,700.00
Something like...
select equipment_no, equipment_desc
from equipment_table
where equipment_status = 'ACTIVE' and year = 2004 and
total_cost = (select sum(costs) from equip_data);
equip_no is in both tables with the costs in the detail
table.
Not sure if I can do the SUM() and have it passed back to the main query for reporting?