I have a requirement of writing table records on to a flat file. Here is the requirement: I have to find all the columns for which the filtering columns are same, in such case the rows are to be written on the same line on the flat file with column name as prefix to the values. Here col1 and col2 are to form a unique record.
Input table:
col1 col2 col3 col4
A B 1 HELLO
C X 5 DEMO
A B 2 TEXT
Output :
A B col31,col4HELLO col32,col4TEXT
C X col35,col4DEMO
Here's a solution which works with the posted sample data and output. It works in two steps: concatenate the columns for each row then use LISTAGG() to aggregate all the rows for combinations of
col1, col2
.