Raj
Raj

Reputation: 1290

How to use LISTAGG to return rows prefixed with quotes

I am trying to return rows which would be useful for setting the in condition in a query. Here is my query

SELECT LISTAGG(PRODUCTID, ',') WITHIN GROUP (ORDER BY RowSequence) FROM DWRE_ITEM_V

which return Order1,Order2

I would like it to return 'Order1','Order2'

I tried using the concat operator || with no luck.

Upvotes: 1

Views: 1345

Answers (1)

schurik
schurik

Reputation: 7928

SELECT LISTAGG(''''||PRODUCTID||'''', ',') WITHIN GROUP (ORDER BY RowSequence) 
FROM DWRE_ITEM_V

Upvotes: 3

Related Questions