-
UNION Query Columns
Hi All,
I have a union query, please see below:
select to_char(some_date,'MON') JAN
from dual
where to_char(some_date,'MON') = &MONTH
UNION
select to_char(some_date,'MON') FEB
from dual
where to_char(some_date,'MON') = &MONTH
UNION
select to_char(some_date,'MON') MAR
from dual
where to_char(some_date,'MON') = &MONTH
Based on the WHERE Clause, the query runs perfectly! Our requirement is to change the column name as well. If the month is JAN should also display JAN, If FEB, then a column name should be FEB, instead no matter what query executes it always display the JAN (First column)
Is there any way to get this?
Thanks in advance.
-
First select rules!
A union ALLWAYS takes the column names from the FIRST select!
"The person who says it cannot be done should not interrupt the person doing it." --Chinese Proverb
-
sample data
Hi,
Please post your sample data
-
Hi,
The query is self-described. If you run you will know my requirement.
Thanks.
-
Originally Posted by ap63
The query is self-described. If you run you will know my requirement.
You are correct AND you already got your answer.
Pablo (Paul) Berzukov
Author of Understanding Database Administration available at amazon and other bookstores.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
-
Originally Posted by ap63
Hi,
The query is self-described. If you run you will know my requirement.
Thanks.
You are asking for help and when we ask you for clarification, you are unwilling to do so???
What are you smoking?
Your query tells us what you have now. Obviously that does NOT satisfy the requirements or you wouldn't have a question to ask. So since it does NOT satisfy the requirements, how can we possibly glean the requirements FROM it??
My assumption is that what you are asking for is a rotated resultset, but unless you make the effort to at least meet us halfway, we will never know. Remember that it is *you* who came to *us* asking for help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|