I have a table of data like the following
User Year Points Value
A 1997 1 10
A 1997 2 30
A 1997 3 40
A 1999 1 70
B 1993 1 7
B 1993 3 4
C 2001 1 10
.....
I want the table to be transformed as such:
User Year Points1 Points2 Points3 ....
A 1997 10 30 40
A 1999 70 null null
B 1993 7 null 4
C 2001 10 null null
......
The range of the Points is unknown at compile time, so it's not just from 1 to 3. It almost like making the Points as the column header in the new table. I suppose SQL PIVOT is a good option, but I haven't got any luck playing with it. I'm using SQL 2008.