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.
Author |
Topic |
csi123
Starting Member
1 Post |
Posted - 2008-09-06 : 20:47:06
|
Hi, This will b of g8 help .There is a table which has the following valuesColumn X columnYX1 YesX2 NoX3 YesIs it possible to get the output as,COLUMND HEADING AS X1 X2 X3 AND VALUES Yes No YesTHANKS |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-07 : 02:41:49
|
Do you have any other column in yourtable?Also wont X1,X2,.. repeat? |
 |
|
yonabout
Posting Yak Master
112 Posts |
Posted - 2008-09-17 : 06:49:38
|
Hi, you could try this:create table #temp(X varchar(2), Y varchar(3))insert into #temp select 'X1', 'Yes' union allselect 'X2', 'No' union allselect 'X3', 'Yes' selectmax(case when x = 'X1' then y end) as 'X1',max(case when x = 'X2' then y end) as 'X2',max(case when x = 'X3' then y end) as 'X3'from #tempbut you will end up having to cater for all the x[n] rows in your table.What are you trying to do?Cheers,Yonabout |
 |
|
|
|
|