Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Turning Rows Into Columns

Author  Topic 

TSQLMan
Posting Yak Master

160 Posts

Posted - 2008-01-05 : 11:11:08
I have a project where I need to turn row data into column data.

The table is like the following:


Support ReadDate Pressure Value
RS1 1/5/2008 456
RS2 1/5/2008 237
RS3 1/5/2008 455
RS1 1/4/2008 427
RS2 1/4/2008 345
RS3 1/4/2008 426
.............


I want to make support the columns, and ReadDate the Rows. There are 130+ Supports in total. I need a way to select each support for a distinct date into a series of column data.

Also if anyone knows of any articles on this topic, I would appreciate the information.

Thanks,

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-01-05 : 11:52:50
Try using PIVOT operator. Refer to BOL for syntax.You can make use of PIVOT in dynamic SQL if the column values are not certain.
Go to Top of Page

TSQLMan
Posting Yak Master

160 Posts

Posted - 2008-01-05 : 11:55:23
quote:
Originally posted by visakh16

Try using PIVOT operator. Refer to BOL for syntax.You can make use of PIVOT in dynamic SQL if the column values are not certain.



I will look at this, Thanks
Go to Top of Page
   

- Advertisement -