Please consider this table:
Table1
NUMBER NAME
----------------------
01 A
01 B
02 A
01 C
02 C
03 C
04 C
I want to convert it to
Table2
NAME NUM01 NUM02 NUM03 NUM04 NUM05
--------------------------------------------------
A 01 02 NULL NULL NULL
B 01 NULL NULL NULL NULL
C 01 02 03 04 NULL
In Table2, the number of columns is fixed (NUM01->05). If NAME value has more than 5 NUMBER values, it just select top 5. If it has less than 5, then fill NULL in remain columns.
I have many different values in NAME column, so I can't think of an appropriate way to convert Table1 right.
Please help me.