sql server - SQL group where clause by employee -
i have query return employees:
name form bob abc bob gfd bob fgf john abc gavin abc jessie ala jessie asf
how if abc exists employee result = yes , if abc doesnt exist no? want see this:
name result bob yes john yes gavin yes jessie no
sql server 2000+, use:
select e.name, coalesce(max(case when e.form = 'abc' 'yes' end), 'no') result employees e group e.name
the max portion return null if none of form values match "abc", coalesce catches return "no".
Comments
Post a Comment