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

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -