I have a table with individual batches which can have multiple sub-batches:
+--------+----------+
¦Batch +Sub-batch ¦
¦--------¦----------¦
¦B_01 ¦SB_01 ¦
¦B_02 ¦SB_02 ¦
¦B_02 ¦SB_03 ¦
¦B_03 ¦SB_04 ¦
+--------+----------+
Where B_ and SB_ are only names (identifiers) of batches, requiring no aggregation.
I would like to return:
+--------+-----------+-----------+
¦Batch +Sub_Batch1 ¦Sub_Batch2 ¦
¦--------¦-----------¦-----------¦
¦B_01 ¦SB_01 ¦ ¦
¦B_02 ¦SB_02 ¦SB_03 ¦
¦B_03 ¦SB_04 ¦ ¦
+--------+-----------+-----------+
It looks like PARTITION BY or PIVOT is the way to go but I can only seem to find aggregate functions.
Any help gratefully received!