I have a table with the below mentioned schema:
InvoiceID int PK,
Date datetime,
Amount Money
I now create a table which contains the Year, Month and Amount from the table above.
Year | Month | Amount
2014 | Dec | 10
I then pivot this table with all the months
select * from (select year(Date) as InvoiceYear, isnull(left(datename(month, date),3),0) as InvoiceMonth, Amount from Invoice) as Sid pivot ( sum(Amount) for InvoiceMonth in (jan,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec)) as P1
The problem I have is that I need to set the months which don't have any amounts to zero instead of null