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
 General SQL Server Forums
 New to SQL Server Programming
 Need values of cells as column header

Author  Topic 

harriere
Starting Member

3 Posts

Posted - 2012-06-06 : 03:51:20
Hi i am new to sql programming..

Let me come to the point..
I am having the follwing data

290780, 'LT'
290780, 'AY'
290781, 'ILS'
290780, 'AY'

i want to output that data as follows:

290780 | 290781 as heading
LT | ILS as values
AY |
AY |


can any one pls help me to do this...i searched a lot i didnt got it...

V.VIJAY
http://harriernet.wordpress.com

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2012-06-06 : 04:29:28
select [290780] = t29780.col2, [290781] = t29781.col2
from
(select col2 seq = row_number() over (order by col2) from tbl where col1 = 290780) t29780
full outer join
(select col2 seq = row_number() over (order by col2) from tbl where col1 = 290781) t29781
on t29780.seq = t29781.seq

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -