Have a Calendar Table called Calendar. This table has a dt field that has a record for every date from 01/01/1998 to 12/31/2030. I have a 2nd table grtbk which holds account numbers. I created a view which cross joins these two tables. So every account is attached to every date. I used the following to create that view called accountdatePLSELECT dbo.Calendar.dt, dbo.grtbk.reknrFROM dbo.Calendar CROSS JOIN dbo.grtbkWHERE (dbo.grtbk.bal_vw = 'W')
Now I have a third table that holds transaction information for the account numbers. I want to sum the amounts of those transactions and group them into Month and Year. If an account does not have any transactions for a period (or no records in the gbkmut), I want the amount to show zero. I tried the following Code but it still only shows accounts that have actual totals and not zero.I think I've tried a dozen different ways and have had no luck. Any suggestions would be greatly appreciated. select accountDatePL.reknr, ISNULL(SUM(dbo.gbkmut.bdr_hfl), 0) AS Amount,YEAR(dbo.gbkmut.datum) AS Year, MONTH(dbo.gbkmut.datum) AS Monthfrom AccountDatePL left outer join gbkmut on accountdatePL.reknr = gbkmut.reknr and gbkmut.transtype <>'V'group by accountdatePL.reknr,YEAR(dbo.gbkmut.datum),MONTH(dbo.gbkmut.datum)order by 'Year',month