Hi,
I'm trying to create a query that combines the predicted spend that is stored on one table with the actual spend that is stored on another for all weeks for which data is available in either table. The problem is that the duration for which data is available is often not the same on both tables so if I use the week column form one table to collect the data often some data from the other table will be missing.
The tables are:
tblApprovedPT tblRawTabs
ProjectYearID ProjectYearID
Week Period (This is the equivalent to week)
Cost Hours (the cost is converted to hours)
tblAnnualPT
Req_Total
Hours_Total This table is use to convert the cost to hours
The SQL I am using for my query at the moment is below, it is a make tabel query. The Having statement limits the query to the sepected ProjectYear ID on the form that calls it.
This though limits my data to the range of weeks in tblApproved_PT_by_Week, how can I get it to look at both tables to find the lowest and highest week numbers and hence give me data for the whole range?
Hope this make sense.
Regards, Robyn
I'm trying to create a query that combines the predicted spend that is stored on one table with the actual spend that is stored on another for all weeks for which data is available in either table. The problem is that the duration for which data is available is often not the same on both tables so if I use the week column form one table to collect the data often some data from the other table will be missing.
The tables are:
tblApprovedPT tblRawTabs
ProjectYearID ProjectYearID
Week Period (This is the equivalent to week)
Cost Hours (the cost is converted to hours)
tblAnnualPT
Req_Total
Hours_Total This table is use to convert the cost to hours
The SQL I am using for my query at the moment is below, it is a make tabel query. The Having statement limits the query to the sepected ProjectYear ID on the form that calls it.
Code:
SELECT Sum(nz(([Cost]/tblAnnualPT!Req_Total)*[Hours_Total])) AS ProjectedHours, Sum(nz(DLookUp("[SumOfHours]","tblRawTabs","[Period]=" & [Week] & "AND tblRawTabs.[ProjectYearID] = '" & tblApproved_PT_by_week.ProjectYearID & "'"),0)) AS WeeklyTabs, tblApproved_PT_by_week.Week, tblApproved_PT_by_week.ProjectYearID INTO tblTempReportGen
FROM tblAnnualPT INNER JOIN tblApproved_PT_by_week ON tblAnnualPT.ProjectYearID = tblApproved_PT_by_week.ProjectYearID
GROUP BY tblApproved_PT_by_week.Week, tblApproved_PT_by_week.ProjectYearID
HAVING (((tblApproved_PT_by_week.ProjectYearID)=[Forms]![frmTempReportGenInfo]![IDList]));
This though limits my data to the range of weeks in tblApproved_PT_by_Week, how can I get it to look at both tables to find the lowest and highest week numbers and hence give me data for the whole range?
Hope this make sense.
Regards, Robyn