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 2005 Forums
 Transact-SQL (2005)
 Query result to a single row per GUID

Author  Topic 

gtaipalus
Starting Member

6 Posts

Posted - 2009-08-10 : 14:53:44
I have a SQL 2005 table that looks like this (2 columns, multiple rows per patient):
PatientID Allergy
---------- --------
1 Fish
1 Peanuts
2 Wheat
2 Dairy
3 Coconut

I need to create a query or temp table that displays the records like this (2 columns and 1 row for each patient):
PatientID Allergy
---------- --------
1 Fish, Peanuts
2 Wheat, Dairy
3 Coconut

I found a similar posting here: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=127132
However this solution moves all PatientID's and Allergies to a single row and single column, instead of a separate row for each patient. Any idea's are appreciated.
Thank you!


GT

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-08-10 : 14:58:39
Dupe:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=130939

Be One with the Optimizer
TG
Go to Top of Page

gtaipalus
Starting Member

6 Posts

Posted - 2009-08-10 : 15:03:40
I know that it is a duplicate. Sorry about the multiple postings.

GT
Go to Top of Page

rajdaksha
Aged Yak Warrior

595 Posts

Posted - 2009-08-10 : 15:10:08
Hi

I have posted the answer here ..http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=130940

can you delete the duplicates if you wish..





-------------------------
R..
http://code.msdn.microsoft.com/SQLExamples/
http://msdn.microsoft.com/hi-in/library/bb500155(en-us).aspx
Go to Top of Page
   

- Advertisement -