select YEAR, [1] as 'Jan', [2] as 'Feb', [3] AS 'Mar', [4] as 'Apr', [5] as 'May', [6] as 'June', [7] as 'July', [8] as 'Aug', [9] as 'Sept', [10] as 'Oct', [11] as 'Nov', [12] as 'Dec',
isnull([1], 0) + isnull([2], 0) + isnull([3], 0) + and so on... as total
from
(SELECT dbo.VW_MT_JournalCountByMonth.Year,
dbo.VW_MT_JournalCountByMonth.Month,
dbo.VW_MT_JournalCountByMonth.EnqCount
from dbo.VW_MT_JournalCountByMonth
where dbo.VW_MT_JournalCountByMonth.Journal= @Journal
) ps
PIVOT
(
sum (enqcount)
for Month in
([1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12])
) as pvt
|