Skip to content
Advertisement

SQL how to exclude rows only if two conditions are met

How do you write a where clause to exclude rows only if two things are true? For instance, I want the inverse of

So I only want to return values where the start_num does not equal the end_num, but only if the time_taken is greater than 100. Both those two things have to be false to remove rows.

I tried

but that doesn’t seem like it gives me the right number of rows in return

Advertisement

Answer

If I understand correctly, you can simply use:

Note that this is not exactly the same, because this also filters out values where any of the column have NULL values. It can easily be tweaked to handle that, if necessary.

This logic can also be written as:

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