I have been working on merging two tables and writing expressions for calculations of columns connecting them through a Service Number that are the same in both tables. When I create the query, I am receiving data for one of the tables where data does not exist - one table has data dating back to 2004 and the other has data for only 2012. I am trying to group by date then by month. I am writing expressions to total the rows in certain columns to create graphs. How do I tell Access not to populate rows with data that does not exist in the one table?
Maybe if you can see the SQL, you might be able to help me. I am not a programmer and not used to working in SQL; I'm more visual, hands on instead of writing the program. Can you help?:
SELECT Format$([Water - Master Database - APS Electrical].[Start Date],'yyyy') AS [Start Date By Year], Format$([Water - Master Database - APS Electrical].[Start Date],'mm') AS [Start Date By Month], Sum([Solar - Master Database - ISH Solar - Electrical].[Solar Total kWh]) AS [SumOfSolar Total kWh], Sum([Solar - Master Database - ISH Solar - Electrical].[Solar Billed Amount]) AS [SumOfSolar Billed Amount], Sum([Water - Master Database - APS Electrical].[Total kWh]) AS [SumOfTotal kWh], Sum([Water - Master Database - APS Electrical].[Billed Amount]) AS [SumOfBilled Amount], Sum([Solar total kwh])+Sum([total kwh]) AS Expr1, Sum([Solar billed amount])+Sum([billed amount]) AS Expr2, (Sum([solar billed amount])+Sum([billed amount]))/(Sum([solar total kwh])+Sum([total kwh])) AS expr3
FROM [Water - Master Database - APS Electrical] RIGHT JOIN [Solar - Master Database - ISH Solar - Electrical] ON [Water - Master Database - APS Electrical].[Service Number] = [Solar - Master Database - ISH Solar - Electrical].[Related APS Service Number]
WHERE ((([Solar - Master Database - ISH Solar - Electrical].[Related APS Service Number]) Like "2286s01285" Or ([Solar - Master Database - ISH Solar - Electrical].[Related APS Service Number]) Like "3646s51287") AND (([Water - Master Database - APS Electrical].[Service Number]) Like "2286s01285" Or ([Water - Master Database - APS Electrical].[Service Number]) Like "3646s51287"))
GROUP BY Format$([Water - Master Database - APS Electrical].[Start Date],'yyyy'), Format$([Water - Master Database - APS Electrical].[Start Date],'mm');