I am working with a SQL problem where I have a variable number of rows with corresponding values that I need to put into columns.
Input table:
id | value
----------
1 | a
1 | b
2 | c
3 | d
3 | e
3 | f
Expected output table:
id | value1 | value2 | value3 | value4
--------------------------------------
1 | a | b | null | null
2 | c | null | null | null
3 | d | e | f | null
Side notes: The value column is the primary key of the input table. The maximum number of output columns should be fixed to 4.