November 29, 2007 at 2:12 am
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
November 29, 2007 at 2:17 am
try the below querry
select id, col1 from table
union all
select id, col2 as 'col1' from table
order by col1
November 29, 2007 at 2:44 am
Thanks working fine
November 29, 2007 at 4:48 am
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[/url] you'll likely increase the number and quality of responses you get to your question.
Jason L. SelburgViewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply