First of all I am sorry but I do not even know how to search what I want so I try it with this question.
I have a table containing some data like this:
Id Number | Periode | Value |
---|---|---|
01 | 1 | 2,2 |
02 | 1 | 3,4 |
03 | 1 | 3,8 |
01 | 2 | 1,9 |
02 | 2 | 8,1 |
03 | 2 | 2,6 |
What I want is a resultset like this:
Id Number | Periode 1 | Periode 2 |
---|---|---|
01 | 2,2 | 1,9 |
02 | 3,4 | 8,1 |
03 | 3,8 | 2,6 |
In the first table I have all my values for all rows in the same structure in the second table I have this stracture lets say "transposed" so each Periode gets there own column with the Value. I hope you can understand what I like to do here.
The amount of periods is variable in the best case. What I have is something like this, but this is not variable I need to adust it everytime the periods changes:
SELECT p.IDNumber,
(SELECT Value FROM #table t where t.IDNumber = p.IDNumber and t.Periode = 1) Periode1,
(SELECT Value FROM #table t where t.IDNumber = p.IDNumber and t.Periode = 2) Periode2,
...
FROM #table p
If you can just send me to the right SQL command I can use for something like this, would be sufficient but as I mentioned above I do not even know how to search for this kind of transformation (If this is even possible).
Thank you in Advance!