Question

having a sql e.g. something like the following resulting in some rows with one value. I search a different sql than SELECT * FROM some_sql which results in one row with comma separated values.


WITH some_sql AS (
  SELECT 1 FROM DUAL
  UNION
  SELECT 2 FROM DUAL
)
SELECT * FROM some_sql

this SQL results in the two rows with value 1 and 2. I seach a SQl resulting in 1,2 without changing the code of 'some_sql'.

OTHER TIPS

Sice you are on 11G you can use LISTAGG

WITH some_sql AS (
  SELECT 1 x FROM DUAL
  UNION
  SELECT 2 x FROM DUAL
)
SELECT LISTAGG(x, ',') WITHIN GROUP(ORDER BY x) FROM some_sql
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top