SQL Server: Modifying this query -
this query gives me information need, i'm wanting display differently if possible. current result: http://i.imgur.com/bfkgfsx.jpg
declare @mainhospital varchar(50)='hospital 1'; select mainemail, chkoutpatient, chkpartb surveypiclist mainhospital = @mainhospital group mainhospital, mainemail, chkoutpatient, chkpartb
i'm trying return 2 different list of mainemail comma-delimited if = "on" in chkoutpatient , chkpartb. 2 cells of data result. 1 header of chkoutpatient list of comma dilmeted emails = "on", , 1 header of chkpartb same.
so chkpartb, this?http://i.imgur.com/rflv24q.jpg
select distinct ', ' + mainemail chkpartb surveypiclist mainhospital = @mainhospital , chkpartb = 'on'
please let me know if question unclear or if need give more info.
with outpatients ( select distinct mainemail surveypiclist mainhospital = @mainhospital , chkoutpatient = 'on' ) ,outpatientsrawcsv ( select ( select ',' + mainemail outpatients xml path('') ) csv ) ,partbs ( select distinct mainemail surveypiclist mainhospital = @mainhospital , chkpartb = 'on' ) ,partbrawcsv ( select ( select ',' + mainemail partbs xml path('') ) csv ) select stuff(outpatientsrawcsv.csv, 1, 1, '') outpatientscsv ,stuff(partbrawcsv.csv, 1, 1, '') partbcsv outpatientsrawcsv cross join partbrawcsv
Comments
Post a Comment