Skip to content
Advertisement

Exclude from resultset based on condition

Given the following table FOO;

| Org | Status |
| X   | CLOSED |
| X   | OPEN   |
| Y   | OPEN   |
| Y   | CLOSED |

How can I select all the records except where org = Y and status = CLOSED

So the resultset looks like:

| Org | Status |
| X   | CLOSED |
| X   | OPEN   |
| Y   | OPEN   |

Advertisement

Answer

You can do this either of these ways:

WHERE (org, status) <> ('Y','CLOSED')
WHERE NOT (org = 'Y' AND status = 'CLOSED')
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement