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)
 Transpose duplicates to comma separated fields

Author  Topic 

sqlserver_newbee
Starting Member

11 Posts

Posted - 2007-10-09 : 15:01:14
Hi all,

I have a table that appears as following

res_id | ques_id | ans_id
=========================
50 | 101 | 2300
50 | 101 | 2301
50 | 102 | 2408
55 | 101 | 2300
55 | 105 | 2450
55 | 105 | 2451

I want to transform it so that I get results as -
res_id | ques_id | ans_id
=========================
50 | 101 | 2300, 2301
50 | 102 | 2408
55 | 101 | 2300
55 | 105 | 2450, 2451

Duplicate Response Id and Question ID should have comma separated answer ids in same row.

Thanks in advance for all the help!



Kristen
Test

22859 Posts

Posted - 2007-10-09 : 15:08:47
See: See: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=55210&SearchTerms=Pivot+table2,Pivot+table,Dynamic+CrossTabs,Dynamic+Cross-Tabs
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-10-10 : 02:32:31
Where do you want to show data?
Also refer
http://sqljunkies.com/WebLog/amachanic/archive/2004/11/10/5065.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -