My Assistant
![]() ![]() |
|
|
Apr 17 2012, 11:50 AM
Post
#1
|
|
|
UtterAccess Ruler Posts: 1,895 From: Massachusetts |
I would like to display the year and month, convert(varchar(7), SvcDt, 120), as the column alias in this query. Any thoughts?
CODE select Grp, PostPd,
sum(case when month(SvcDt)=1 then Charge_Amt else 0 end) as Jan, sum(case when month(SvcDt)=2 then Charge_Amt else 0 end) as Feb, sum(case when month(SvcDt)=3 then Charge_Amt else 0 end) as Mar, sum(case when month(SvcDt)=4 then Charge_Amt else 0 end) as Apr, sum(case when month(SvcDt)=5 then Charge_Amt else 0 end) as Mar, sum(case when month(SvcDt)=6 then Charge_Amt else 0 end) as Jun, sum(case when month(SvcDt)=7 then Charge_Amt else 0 end) as Jul, sum(case when month(SvcDt)=8 then Charge_Amt else 0 end) as Aug, sum(case when month(SvcDt)=9 then Charge_Amt else 0 end) as Sep, sum(case when month(SvcDt)=10 then Charge_Amt else 0 end) as Oct, sum(case when month(SvcDt)=11 then Charge_Amt else 0 end) as Nov, sum(case when month(SvcDt)=12 then Charge_Amt else 0 end) as Dec from formatIDX_Income where year(SvcDt)='2011' and PayCode='99' group by Grp, PostPd order by Grp, PostPd |
|
|
|
Apr 17 2012, 02:01 PM
Post
#2
|
|
|
UtterAccess VIP Posts: 17,610 From: Don Mills, ON (Canada) |
You mean you want the alias to be a variable? AFAIK, it can't be done.
|
|
|
|
Apr 17 2012, 02:25 PM
Post
#3
|
|
|
UtterAccess Ruler Posts: 1,895 From: Massachusetts |
Thanx. That settles that.
|
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 19th May 2013 - 09:29 AM |