How to "flatten" multiple rows with same ID (Oracle 11g) by concatenating **multiple** fields per row?

by nutty about natty   Last Updated August 14, 2019 10:06 AM

I'm connected to an Oracle Database (11g Release 2 - 11.2.0.4).

I'd like to "flatten"/"merge" all rows with the same ID, pretty much as is well delineated here: https://www.w3resource.com/mysql/aggregate-functions-and-grouping/aggregate-functions-and-grouping-group_concat.php

enter image description here

However, in this example the "concatenation" is applied only to one field/column; I'd want to apply it to several fields/columns.

Also, I'd only want to concatenate unique/distinct entries (in the above example that would be

P002 | CA003

instead of the duplication

P002 | CA003,CA003


Related links:

Eliminate duplicates in ListAgg (Oracle)

https://livesql.oracle.com/apex/livesql/file/content_HT1O85E4BHSBWN93G1B3M8SI2.html

https://stackoverflow.com/questions/11510870/listagg-in-oracle-to-return-distinct-values



Related Questions




Convert Concat's datatype to varchar

Updated October 04, 2018 13:06 PM

Group stored procedures in oracle

Updated May 14, 2018 15:06 PM