|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: Wednesday, October 14, 2009 1:56 AM
Points: 438,
Visits: 754
|
|
Hi,
how to make a column into a row using select statement. For ex,
ID Col1 Col2 -------------------- 1 A B 2 D E
Output Should like this.
ID Col1 ------------ 1 A 1 B 2 D 2 E
Thanks in Advance
|
|
|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: Wednesday, March 10, 2010 3:20 AM
Points: 422,
Visits: 91
|
|
try the below querry select id, col1 from table union all select id, col2 as 'col1' from table order by col1
|
|
|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: Wednesday, October 14, 2009 1:56 AM
Points: 438,
Visits: 754
|
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Yesterday @ 3:47 PM
Points: 1,287,
Visits: 1,699
|
|
And for more complex "Columns into Rows/Rows into Columns" Look up the PIVOT and UNPIVOT functions new to 2005. They've proven quite handy.
~Why push the envelope when you can just open it?
Jason Selburg
|
|
|
|