selecting rows from duplicate values where a field has never changed

If you want just the TestNames you can group by testname and set the condition in the HAVING clause:

select TestName
from tablename
group by TestName
having sum(Result <> 'FAIL') = 0

If you want all the rows for the TestNames that never passed, you can use NOT EXISTS:

select t.* from tablename t
where not exists (select 1 from tablename where TestName = t.TestName and Result <> 'FAIL')

See the demo.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top