EXCEPT / MINUS

The SQL EXCEPT Operator

EXCEPT returns rows from the first query that are not in the second. Oracle calls it MINUS.

Example

Products that have never been ordered in a quantity of 10 or more:

SELECT ProductID FROM Products
EXCEPT
SELECT ProductID FROM OrderDetails WHERE Quantity >= 10;

Result: 2 rows

ProductID
2
6

Order Matters

A EXCEPT B is not the same as B EXCEPT A, just like subtraction.

-- Oracle
SELECT ProductID FROM Products
MINUS
SELECT ProductID FROM OrderDetails WHERE Quantity >= 10;