This is more of a SQL question, but figured I would post here as this group has always been super-helpful : )
I want to, in the course of the SQL code, rename a column depending on what is in the column. Specifically, I am doing a count of customers by month, and want the column name to reflect each particular month. I have the month data in my table, but am stumped as to how to get it to be the specific column's name. Anyone have any ideas?
Can you give us the Layout of the table currently? And maybe some made up sample data and explain how you want the layout changed?
You could try renaming the column on the select.
In ANSI sql you can simply change the column name on the select by using NAMED
sel MyCol ( NAMED jan );
I guess if the Data is number 01 - 12 and you want ASCII names "Jan" - "Dec"
you could use a Case statement or a translation table.
sel (case (MyCol) when 1 then 'Jan' when 2 then 'Feb' when 3 then 'Mar' when 4 then 'Apr' when 5 then 'May' when 6 then 'Jun' when 7 then 'Jul' when 8 then 'Aug' when 9 then 'Sep' when 10 then 'Oct' when 11 then 'Nov' when 12 then 'Dec' end) As My_Month;