|
|
|
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: Monday, February 04, 2013 7:02 AM
Points: 459,
Visits: 94
|
|
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
|
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Wednesday, May 15, 2013 7:55 AM
Points: 2,582,
Visits: 3,552
|
|
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.
______________________________________________________________________
Personal Motto: Why push the envelope when you can just open it?
If you follow the direction given HERE you'll likely increase the number and quality of responses you get to your question.
Jason L. Selburg
|
|
|
|