Hi
Suppose i have the following data in a table:
ID Type Preis
1 1 10
1 2 20
1 3 30
and now i want it reorganized like this:
ID Preis_A Preis_B Preis_C
1 10 20 30
How can i do this in t-sql?
Hi
Suppose i have the following data in a table:
ID Type Preis
1 1 10
1 2 20
1 3 30
and now i want it reorganized like this:
ID Preis_A Preis_B Preis_C
1 10 20 30
How can i do this in t-sql?
Which version of SQL Server are you using? Search here for Cross-Tab and/or Pivot.
I'm using MSSQL 2008.
So far i've understand all the proposed solution and i think pivot is nice. However i might add that i sometimes i need to group types e.g. Preis_A = Type 1 and 10.
And regarding performance is pivot faster than using subqueries as proposed by Daniel Vasallo?