I've got this situation where I think the best solution is using a pivot function, but I don't really know how to. Or maybe there is a much better way to do this...
I got this table as a source :
ID | version | code | property | value
-----|---------|------|----------|------
110| 1| AA| prop1| 10
110| 1| AA| prop2| 20
110| 1| AA| prop3| 30
110| 1| BB| prop1| 10
110| 1| BB| prop2| 40
110| 1| BB| prop3| 20
110| 2| AA| prop1| 50
120| 1| BB| prop2| 60
120| 2| AA| prop3| 80
What I want to end up with is the following :
ID | version | code | prop1 | prop2 | prop3
-----|---------|------|-------|-------|------
110| 1| AA| 10| 20| 30
110| 1| BB| 10| 40| 20
110| 2| AA| 50| |
120| 1| BB| | 60|
120| 2| AA| | | 80
So you see I don't do aggregation, just a pivot over the first 3 tables. Is this posible in TSQL, I'm using SQL Server 2012.
prop1,prop2andprop3?SUM,MINorMAX(I generally prefer the latter two since they apply to a wider range of types)