Solved

Concatenate Aliased Columns

Posted on 2010-11-18
9
2,068 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:Roberto Madro R.
  • 5
  • 3
9 Comments
 
LVL 74

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 74

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
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 74

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
 
LVL 74

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:
Roberto Madro R. earned 0 total points
ID: 34168216
your feedback seems to spur another idea that worked, thank you sdstuber.
0
 
LVL 74

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:Roberto Madro R.
ID: 34168252
Thx
0
 

Author Closing Comment

by:Roberto Madro R.
ID: 34195076
.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
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…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

808 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