Bill Crawley
May 1st, 2009, 05:44 AM
Hi ALL,
Using SQLServer 2005 I have a table made up of the following format:
Id = primary key
Type = Primary key
Year = Primary Key
Qty
If I do a simple select say Select * from mytable I get the expected output of data in the following format.
512 a 1 300
512 a 2 220 etc
I want to turn the data on it's side so that I get it in the following format Effectively Grouped by id and type
Id Type Year1 Year2
512 a 300 220
Any ideas how I get an output like this without using a cursor and placing in temp table first? I was wondering if there is a single Query that would do the trick.
Using SQLServer 2005 I have a table made up of the following format:
Id = primary key
Type = Primary key
Year = Primary Key
Qty
If I do a simple select say Select * from mytable I get the expected output of data in the following format.
512 a 1 300
512 a 2 220 etc
I want to turn the data on it's side so that I get it in the following format Effectively Grouped by id and type
Id Type Year1 Year2
512 a 300 220
Any ideas how I get an output like this without using a cursor and placing in temp table first? I was wondering if there is a single Query that would do the trick.