I did not find any suitable previous answers hence posting the question. I need to convert rows to columns. The PIVOT examples all convert the rows to a single column whereas my requirement is multiple columns. My table looks like this
Type ID
test1 10
test1 20
test1 30
test2 10
test2 40
I would like it to be
Type ID Type ID
test1 10 test2 10
test1 20 test2 40
test1 30
Appreciate your suggestions/inputs!
You could enumerate rows with
row_number()
and makepivot
:SQLFiddle demo
If the 'ID' column is the primarykey you can only have one column as primarykey in the table.