I need assistance in wirting this sql statement from 4 tables, and not sure how to write it. I have the below example...Any help will be greatly appreciated...thx
Table1 Table2 Table3 Table4
JobDate JobDate JobDate JobDate
JobNumber JobNumber JobNumber JobNumber
EquipSubtotal LaborSubTotal SuppliesTotal MiscExpenseSubTotal
Input Variables: @JobNumber, @StartDate, @EndDate
Here is 4 Tables. The end result I am looking for:
EquipmentTotal LaborTotal HotelTotal SuppliesTotal MiscExpenseTotal
Equipment Total LaborTotal HotelTotal SuppliesTotal MiscExpenseTotal
Table1 contains multiple entries for each day for each piece of equipment(Subtotal), but I only want the Sum(EquipSubtotal) as equipmentTotal returned for that day.
Table2 contains multiple rows for each day for Hotel and Labor, but only need the Sum(HotelSubtotal) and Sum(LaborSubTotal ) returned for each day
Table3 contains only 1 row of the sum of the supplies total for each day, there is no multiple entries for each day, just once per day and the total.
Table4 contains multiple rows for each day for mis expenses. I need to only return the Sum(MiscExpenseSubTotal) for that day.
There may not be a anything for that day in 1 of the tables, but I need the other tables to be returned in the query. All Tables have a default of $0.00 so there is no Nulls.