SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Need values of cells as column header
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

harriere
Starting Member

India
3 Posts

Posted - 06/06/2012 :  03:51:20  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

United Kingdom
3383 Posts

Posted - 06/06/2012 :  04:29:28  Show Profile  Visit nigelrivett's Homepage  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000