Ak Ash Ak Ash - 1 year ago 76
SQL Question

How to get formatted SQL query result

Consider this a table

Code Name City Salary
1 Mark LA 12000
2 Selena NY 6000
3 Justin USA 50000
4 John CN 3000

I want result like this

John lives in `CN` and his salary is 3000.
Justin lives in `USA` and his salary is 50000.

How can I do so in Oracle?

If there is different method then explain them also .

Answer Source

To concatenate values in SQL you use ||. Character values are supplied using single quotes: '.

Putting that together you need to use:

select name ||' lives in "'||city||'" and his/her salary is '||salary
from the_table;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download