Skip to content
Advertisement

sql query for grouping column into row

So, I have table like this

and I want to make query so the result is like

or

I have try to use GROUP BY but I dont know how to get the slot number.

Please help, thank you!

Advertisement

Answer

With conditional aggregation:

See the demo.
Results:

And for the 2nd case use group_concat():

See the demo.
Results:

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement