SELECT * FROM (
Select
SUM (case MONTH (purchase_date) if ' 1 ' then Summoney else 0 end) as January,
SUM (case MONTH (purchase_date) if ' 2 ' then Summoney else 0 end) as February,
SUM (case MONTH (purchase_date) if ' 3 ' then Summoney else 0 end) as March,
SUM (case MONTH (purchase_date) if ' 4 ' then Summoney else 0 end) as April,
SUM (case MONTH (purchase_date) if ' 5 ' then Summoney else 0 end) as May,
SUM (case MONTH (purchase_date) if ' 6 ' then Summoney else 0 end) as June,
SUM (case MONTH (purchase_date) if ' 7 ' then Summoney else 0 end) as July,
SUM (case MONTH (purchase_date) if ' 8 ' then Summoney else 0 end) as August,
SUM (case MONTH (purchase_date) if ' 9 ' then Summoney else 0 end) as September,
SUM (case MONTH (purchase_date) If ' then Summoney else 0 end) as October,
SUM (case MONTH (purchase_date) when ' one ' then Summoney else 0 end) as November,
SUM (case MONTH (purchase_date) when ' Summoney else 0 end ' as December
From Purchase) TD Unpivot (Moneys-months in
(January,february,march,april,may,june,july,august,september,october,november,december)) As Temp
SQL Server row to column (statistics sum of 1-12 months of data in a year)