Rishi Deorukhkar
Rishi Deorukhkar

Reputation: 189

How to get the fields from listagg in quotes?

Consider the table STUDENTS:

---------------------
|Sr.No|    Name     |
---------------------  
| 1   |    Jon      |
---------------------
| 2   |    Rob      |
---------------------
| 3   |    Bran     |
---------------------

Using below query we get:

select listagg(Name, ',') within group (order by Name) from STUDENTS

From this we will get :

Jon,Rob,Bran

How do we get something like

"Jon","Rob","Bran"

Upvotes: 3

Views: 5029

Answers (1)

kevinskio
kevinskio

Reputation: 4551

this should do the job

select listagg('"'||Name||'"', ',') within group (order by Name) from STUDENTS;

Upvotes: 15

Related Questions