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.
Author |
Topic |
sross81
Posting Yak Master
228 Posts |
Posted - 2011-06-24 : 12:16:56
|
Hello,I have been searching for a way to make this query work. I thought Coalesce would work, but from what I read it doesn't seem to be what I am looking for. I have done case statements and concatenated multiple fields into one list, but I have not found a way to do it with the same field. I have this query.select distinct a.person_id,c.brand_namefrom person aleft outer join patient_medication b on a.person_id = b.person_idleft outer join fdb_medication c on b.ndc_id = c.ndc_idwhere c.brand_name IN('Lescol','Lipitor','Torvast','Zocor','Lipex','Pravachol','Selektine','Lipostat','Crestor','Altocor','Mevacor')and (b.date_stopped is null or b.date_stopped = '')My results areperson id, brand_name1, Lescol1, LipitorI want them to beperson_id, brand_name1, (Lescol, Lipitor)Is that possible?Thanks in Advance!Sherri |
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
|
sross81
Posting Yak Master
228 Posts |
Posted - 2011-06-24 : 13:59:50
|
This site is alot easier to understand and follow. I just thought I would share in case anyone else needs help. Thanks for giving me an idea of what to search on.[url]http://sqlwithmanoj.wordpress.com/2010/09/16/combine-multiple-rows-to-csv-string-and-vice-versa/[/url]quote: Originally posted by nigelrivett seehttp://www.nigelrivett.net/SQLTsql/CSVStringSQL.html==========================================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.
Thanks in Advance!Sherri |
 |
|
|
|
|
|
|