Solved

Concatenate Aliased Columns

Posted on 2010-11-18
9
1,977 Views
Last Modified: 2012-05-10
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..

0
Comment
Question by:codedigger
  • 5
  • 3
9 Comments
 
LVL 73

Expert Comment

by:sdstuber
ID: 34167616
Don't concatenate the alias

empFN  ||','|| empLN ||','|| JobID  ||','|| xxxxx  as "Some New Name"
0
 
LVL 3

Expert Comment

by:mpaladugu
ID: 34167884
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
 
LVL 73

Expert Comment

by:sdstuber
ID: 34167909
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
 
LVL 73

Assisted Solution

by:sdstuber
sdstuber earned 250 total points
ID: 34167928
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 73

Expert Comment

by:sdstuber
ID: 34167942
Note the double quotes.

If your aliases are not normal legal identifiers you need to double quote them any place they are propogated
0
 

Accepted Solution

by:
codedigger earned 0 total points
ID: 34168216
your feedback seems to spur another idea that worked, thank you sdstuber.
0
 
LVL 73

Expert Comment

by:sdstuber
ID: 34168246
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
 

Author Comment

by:codedigger
ID: 34168252
Thx
0
 

Author Closing Comment

by:codedigger
ID: 34195076
.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now