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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Output Row to Column

Author  Topic 

yen
Starting Member

1 Post

Posted - 2004-02-16 : 14:48:05
How can i make the Sql result like this. My table details are like this

id name
1 a
2 b
3 c
4 d
5 e
6 f
7 g

i want the result like this

id name id name id name
1 a 2 b 3 c
4 d 5 e 6 f
7 g

how can i do this. Any idea

Thanks in advance

SamC
White Water Yakist

3467 Posts

Posted - 2004-02-16 : 16:09:11
It'll take unions like this (assumes a fixed number of columns)

SELECT id1 AS ID, name1 AS Name FROM MyTable
UNION ALL
SELECT id2, name2 FROM MyTable
UNION ALL
SELECT id3, name3 FROM MyTable
ORDER BY ID, Name
Sam
Go to Top of Page

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2004-02-17 : 01:01:41
You can search for articles relating to crosstabs at this forum.
One such article is this one. http://www.sqlteam.com/item.asp?ItemID=2955
These articles on crosstabs are quite usefull
Go to Top of Page
   

- Advertisement -