Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Concatenate Aliased Columns

Posted on 2010-11-18
9
Medium Priority
?
2,264 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
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…

609 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