Skip to content
Advertisement

How to look for missing rows within a group?

Consider the data below. I am trying to find situations where in a specific RequestID, there is an Attempt: 0, but Attempt: 2 is missing.

I’ve tried looking for Attempt: 0 with a WHERE predicate and doing NOT EXISTS ... Attempt: 2 in a subquery, but it doesn’t return the right data.

How do I find the RequestIDs with missing Attempt: 2?

Advertisement

Answer

You can use not exists like this:

Another possibility is aggregation:

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement