SQLTeam.com | Weblogs | Forums

Unique data (don't repeat result)


#1

In my simple table I only want to report rows that pass and report those only once. So the result should have Unit 1 and 2 once.

Thanks,
JH

sql%20table


#2
SELECT Unit
FROM simple_table
GROUP BY Unit
HAVING MAX(CASE WHEN Result = 'pass' THEN 1 ELSE 0 END) = 1 AND
    MAX(CASE WHEN Result = 'fail' THEN 1 ELSE 0 END) = 0
ORDER BY Unit

#3

a little simpler

select distinct Unit
  from simple_table
  where Result = 'pass'

#4

Only if assume a given Unit can't have both Fail and Pass in it ... I'm not willing to assume that at all, given the q was posed.