Concatenate Aliased Columns

What's the best way to concatenate aliased columns, a quick example;

Select empFN as "First Name" ||','|| empLN as "Last Name" ||','|| JobID as "Job Class" ||','|| xxxxx
From Emp
Where .....etc..

Roberto Madro R.Programmer AnalystAsked:
Who is Participating?
 
Roberto Madro R.Programmer AnalystAuthor Commented:
your feedback seems to spur another idea that worked, thank you sdstuber.
0
 
sdstuberCommented:
Don't concatenate the alias

empFN  ||','|| empLN ||','|| JobID  ||','|| xxxxx  as "Some New Name"
0
 
mpaladuguCommented:
if there are only 2 columns to con cat, you can also use concat(col1, col2) function in oracle. But this is limited to concatenating only 2 columns.  easiest is what said above.

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
sdstuberCommented:
even if you use concat,  you still don't concatenate the aliases, you concatenate the columns.

the only thing aliased is the resulting string.
0
 
sdstuberCommented:
alternately,  if you already have aliased results.

you can wrap your query in an inline view and then concatenate the columns from that view, which will be the aliases.

select "First Name" || ',' || "Last Name" || ',' || "Job Class" || ',' ||  xxxxx
from
(select empFN as "First Name" , empLN as "Last Name" ,  JobID as "Job Class" ,  xxxxx
from.....
)
0
 
sdstuberCommented:
Note the double quotes.

If your aliases are not normal legal identifiers you need to double quote them any place they are propogated
0
 
sdstuberCommented:
glad I could help,  

your questions will close immeidately if you don't accept your own post as an answer.
Since http:#34168216  isn't really an answer, it doesn't make sense to accept it anyway.

You should only accept your own answer if you have added something beyond what is in the other posts.
0
 
Roberto Madro R.Programmer AnalystAuthor Commented:
Thx
0
 
Roberto Madro R.Programmer AnalystAuthor Commented:
.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.