I have a situation where I would like to put three different columns, each which have multiple rows, into a single row.
I am using this code, which works to give me all of the first columns, then the second columns, then the third.
, '(' ||(LISTAGG(billing_item_id, ', ') WITHIN GROUP (order by eduid) || ' | ' || LISTAGG(billing_item_amount, ', ') WITHIN GROUP (order by eduid)) || ' | ' || LISTAGG(REGEXP_SUBSTR(instance_name,'^[A-Z]{3,4} [0-9]{4}'), ', ') WITHIN GROUP (order by eduid) || ')' as billing
The results are:
321718277 Anon Person SENIOR HIGH SCHOOL 2022-2023 (606547, 606550 | 225, 225 | ENGL 1175, MATH 1153)
What I would like to see is
321718277 Anon Person SENIOR HIGH SCHOOL 2022-2023 (606547|225|ENGL 1175),(606550|225|MATH 1153)
The billing id, 606547, amount 225, and course ENGL 1175 are all on the same row.
Concatenate value within
listagg, notlistaggs themselves. Something like this: