I have tried doing pivot tables but only for fixed number of rows.
I have the following records:
ID CODE
=== ====
1 AAA
1 BBB
1 CCC
2 DDD
3 EEE
3 FFF
4 GGG
4 HHH
4 III
4 JJJ
And my expected result is:
ID CODE1 CODE2 CODE3 CODE4
=== ===== ===== ===== =====
1 AAA BBB CCC
2 DDD
3 EEE FFF
4 GGG HHH III JJJ
Take note that the number of rows returned per id is not fixed. I want to avoid cursor as much as possible.