I am running a SELECT statement on a table to produce a list of costs asssociated with training and development exercises.The results table shows cost SUMs grouped by month, along with different currencies, like this:Date regionCultureCode Totals-------------------------------------------------December 2003 £ GBP 175.00February 2004 £ GBP 1,880.00December 2004 £ GBP 970.00February 2005 £ GBP 1,020.00August 2005 £ GBP 200.00October 2005 £ GBP 409.00January 2007 £ GBP 4,010.00January 2007 $ USD 14,950.00January 2007 kr NOK 250.00February 2007 £ GBP 720.00March 2007 £ GBP 2,010.00April 2007 £ GBP 1,720.00May 2007 £ GBP 1,420.00December 2009 £ GBP 5,850.00December 2009 $ USD 3,570.00December 2009 kr NOK 780.00
This is achieve by running an initial SELECT statement and saving the results into a table varialbe (@tmp). I then run the query to group the results:SELECT SUM(costAmount) AS [Totals], datename(month, [date])+' '+CAST(Year(date) AS nvarchar) AS [Date], regionCultureCodeFROM @tmp GROUP BY regionCultureID, regionCultureCode, datename(month, [date])+' '+CAST(Year(date) AS nvarchar), month([date]), year([date])ORDER BY year([date]), month([date]), regionCultureCode
How can I get the results to show EVERY month even if there is no data for that particular month? Ideally I'd like to show every currency for every month between the first and last months (these dates being used as parameters in the intial query).Please help! 