Ak Ash Ak Ash - 5 months ago 35
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 .


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;