Hi All,
My Oracle version:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
PL/SQL Release 11.2.0.4.0 - Production
The following is an example:
Table A
PID ID Description
A 1 Have
A 2 a nice day.
B 3 Nice
B 4 Work.
C 5 Yes
C 6 we can
C 7 do
C 8 this work!
Output of the SQL should be:
PID Description ID
A Have a nice day. 1
B Nice Work. 3
C Yes we can do this work! 5
or
PID Description ID
A Have a nice day. 2
B Nice Work. 3
C Yes we can do this work! 7
Note: The ID column may have any value from the group.
I am using LISTAGG and my sample SQL is:
SELECT PID, LISTAGG(Description, ' ') WITHIN GROUP (ORDER BY NULL) Description
FROM A
GROUP BY PID;
I am not sure and need help on how to bring ID in the sample output.