I have the scenario below to capture the final charge and payments due where facility and report dates are primary keys in both tables:
Code:
Table Productivity: Facility, Report Date, Charges, Payments
Table Adjustments: Facility, Report Date, Charges, Payments
Query Final: Facility, Report Date, (Productivity.Charge+Adjustments.Charges), (Productivity.Payments+Adjustments.Adjustments)
In the table adjustments there is not always a facility and run date associated with a pair in the productivity table. So therefore, my query only returns values where there are pairs in both tables through a LEFT JOIN and a one to one relationship. (e.g. Facility A 10/1/2010 has to be in both tables for my query to work or else a blank value will be in the query, but there is not always adjustments every report date). I am new to access so maybe I am missing something obvious. The SQL looks like this for just the charge portion:
Code:
SELECT Productivity.Facility, Productivity.[Report Date], [Productivity].[Charge]+[Adjustments].[Charge] AS Charge
FROM Productivity LEFT JOIN [Adjustments] ON (Productivity.[Report Date] = [Adjustments].[Report Date]) AND (Productivity.Facility = [Adjustments].Facility);