Oracle
 sql >> Database >  >> RDS >> Oracle

Formattazione di stringhe utilizzando LISTAGG in Oracle. virgolette singole di escape ` ' `

Potresti usare:

SELECT LISTAGG('''' || student_name || '''',',') 
       WITHIN GROUP (ORDER BY student_name)
FROM students;

o utilizzando ENQUOTE_LITERAL funzione:

SELECT LISTAGG(DBMS_ASSERT.ENQUOTE_LITERAL(student_name),',') 
       WITHIN GROUP (ORDER BY student_name) AS r
FROM students;

Demo DBFiddle