mikaelsnavy
10/22/2014 - 8:42 PM

Multiple Rows into One

Multiple Rows into One

 (select stuff(
         (
            select distinct ', ' + rtrim(pak_value) 
            from e_pstor 
            where e_pstor.ptype_id = '{55266899-ca35-4690-afaa-9af9b3b98ab2}' /* Code: Pharmacy Supplemental Clinical Rationale */
               and e_pstor.source_id = e_note.ct_id
               and e_pstor.pak_value > ''
            order by ', ' + rtrim(pak_value)
            for xml path(''),type).value('.','varchar(max)'),1,1,'')
   ) AS Pharmacy_Supplemental_Clinical_Rationale_value