?
Solved

Concatenate Aliased Columns

Posted on 2010-11-18
9
Medium Priority
?
2,217 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.
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
LVL 74

Assisted Solution

by:sdstuber
sdstuber earned 1000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
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 video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.
Suggested Courses

764 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