Also, this derivative of Ganesh's answer yields the same response, and is amount-neutral:
select 'Total' as Months
,Cast(max(case when Months = '01' then Cash end) as varchar(20)) [1]
,Cast(max(case when Months = '02' then Cash end) as varchar(20)) [2]
,Cast(max(case when Months = '03' then Cash end) as varchar(20)) [3]
,Cast(max(case when Months = '04' then Cash end) as varchar(20)) [4]
,Cast(max(case when Months = '05' then Cash end) as varchar(20)) [5]
,Cast(max(case when Months = '06' then Cash end) as varchar(20)) [6]
,Cast(max(case when Months = '07' then Cash end) as varchar(20)) [7]
,Cast(max(case when Months = '08' then Cash end) as varchar(20)) [8]
,Cast(max(case when Months = '09' then Cash end) as varchar(20)) [9]
,Cast(max(case when Months = '10' then Cash end) as varchar(20)) [10]
,Cast(max(case when Months = '11' then Cash end) as varchar(20)) [11]
,Cast(max(case when Months = '12' then Cash end) as varchar(20)) [12]
,Cast(max(case when Months = '13' then Cash end) as varchar(20)) [13]
,Cast(max(case when Months = '14' then Cash end) as varchar(20)) [14]
,Cast(max(case when Months = '15' then Cash end) as varchar(20)) [15]
from @T
No comments:
Post a Comment