Skip to content

Instantly share code, notes, and snippets.

@mikaelweave
Last active November 9, 2017 16:51
Show Gist options
  • Save mikaelweave/cdda19e16c7b77efbcbf to your computer and use it in GitHub Desktop.
Save mikaelweave/cdda19e16c7b77efbcbf to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment