I am working on an sql server 2008 database.
I have a table like this”
Id Year Series Value
----+------+--------+------
1 1990 a 1.5
1 1990 b 1.6
1 1990 c 1.7
1 1991 a 1.8
1 1991 b 1.9
1 1991 c 2.5
Is there a query that can select the values and return them like this?
Year a b c
------+------+--------+------
1990 1.5 1.6 1.7
1991 1.8 1.9 2.5
Thanks a lot for any help.
If series is fixed to a,b,c you can do this:
If there would be other values you can use dynamic pivot:
In a scenario with fixed series, there is also possibility with CROSS JOIN: