sql - SELECT CASE when DISTINCT -


i need list cities in database there active employee. if city exists in more 1 state, want append state name it. i'm trying like:

select locations.locationid,     case         when locations.city not distinct             locations.city + '(' + isnull(locations.state,'') + ')'         else locations.city     end locationdescription locations     inner join employees on locations.locationid = employees.locationid employees.active=1  order locationdescription 

obviously isn't correct syntax i'm using distinct, not sure how go this.

i go option add state every time, however, if want way can use group by , in clauses...

when locations.city in (select locations.city location group city having count(*) > 1) 

Comments