Skip to content
/Chapter 15 · Set Operations
Lesson 15.4·garden_shop
Lesson 15.4

SQL EXCEPT

EXCEPT subtracts one compatible result set from another.

EXCEPT returns rows from the first query that do not appear in the second query. It reads like subtraction: start with a full list, then remove the rows found by another SELECT.

This can express missing-match questions clearly, especially when the final output is a simple list of values or identifiers.

Pattern
select value_column
from full_list
except
select value_column
from values_to_remove

The selected row is the comparison

EXCEPT compares every selected column. Keep both sides aligned and avoid adding extra columns to only one side of the query.

Schema · Garden ShopTable · orders6 columns · 24 rows
Table · orders

One row per order. Unshipped orders have a null shipped_date.

6 columns · 24 rows
order_id intcustomer_id intorder_date dateshipped_date datestatus textcoupon_code text
Your task

Return customer_id, first_name, andlast_name for active customers who havenever had a shipped order.

SQL Workbench
query.sqlgarden_shop · SQL engine loading
⌘↵ to run
·
Expected answer
  • Columns: customer_id, first_name, last_name.
  • Rows: active customers with no shipped order rows.
  • EXCEPT compares the full selected row, so both SELECT statements use the same columns.
← Previous · 15.3 INTERSECT
✓ Chapter 15 complete

You finished “Set Operations.”

Nice work. Ready to start the next one?

Start Chapter 16: Summary Reports & Pivots →Begins with 16.1 Pivoting with conditional aggregation