Skip to content
Advertisement

sql: long to wide format without using PIVOT

I have a table like the following:

I want to convert the data to wide format like the following:

the SQL I used does not have a pivot choice so I am wondering how to convert the long format to wide without using PIVOT.

Advertisement

Answer

If I understand your question correctly, you can do conditional aggregation:

Maybe you want to use actual_value to pivot instead of the val[n] columns:

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