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

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -