Random guy
Random guy

Reputation: 923

Output not coming as expected while using sql in oracle

I have a table temp_zzz which has:

enter image description here

My expected output is:

dataset pay bitable condt
A       B   C,E     ZZ
P       Q   D,F     YY

I have learned listaggs in oracle,but its not giving me expected output.

I tried is:

SELECT LISTAGG(bitable, ', ') WITHIN GROUP (ORDER BY condt) "Product_Listing"
FROM temp_zzz group by condt;

It gave me :

Product_Listing
D, F
C, E

Is it possbile to get the expected result I expected?

Upvotes: 1

Views: 23

Answers (1)

Lukasz Szozda
Lukasz Szozda

Reputation: 175676

Yes, it is possible:

SELECT dataset,
       condt,
       MIN(pay) AS pay,
       LISTAGG(bitable, ', ') WITHIN GROUP (ORDER BY condt) "Product_Listing"
FROM temp_zzz 
group by dataset,condt;

Upvotes: 1

Related Questions