Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Can we change alias name dynamically

452779Jun 26 2006 — edited Jun 26 2006
Hi ALL,

I have a requirement in one of my report to change the Column Heading Dynamically based on column value.

eg : My query is like this

SELECT TO_CHAR(CONTROL_DATE, 'YYYY') "2006 YTD",
TO_CHAR(ADD_MONTHS(CONTROL_DATE, -12),'YYYY') as "2005 YTD"
FROM R_GRC_CONTROL WHERE CONTROL_ID = 2


---------------------------------------OUTPUT is in this format------------------------
2006 YTD 2005 YTD

2006 2005
---------------------------------------------------------------------------------------



Now what I want is column heading should change dynamically i.e "2006 YTD" next year it will like "2007 YTD" and so on.


------------------------------ Expected output next year---------------------------------------------

2007 YTD 2006 YTD

2007 2006
-------------------------------------------------------------------------------------------------------------------


So , is it possible to change the alias name dynamically based on column value?

Please advise


Many Thanks
Dikshit
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 24 2006
Added on Jun 26 2006
3 comments
601 views