Hi, I have the below query and it return me incorrect result i.e. as below but I need something like in desired result. Can you please help?
What I mean is I need null values as well in between commas.
WITH t AS (
SELECT NULL c1, 'a' c2
FROM dual UNION
SELECT 'b' c1, NULL c2
FROM dual
) SELECT LISTAGG (c1, ',') WITHIN
GROUP (ORDER BY 1) AS c1
, LISTAGG (c2, ',') WITHIN
GROUP (ORDER BY 1) AS c2
FROM t
Result -
c1 c2
b a
Desired result -
c1 c2
null, b a, null