SQLMarrow / Course Academy Experience

SQL & Databases Masterclass Course

Welcome to the ultimate postgresql tutorial for beginners 2026. Work through interactive sql practice problems with solutions, master our comprehensive sql window functions tutorial modules, and prepare for tough sql interview questions at Google and Amazon entirely in your browser. Claim your course completion XP and build production-ready database mastery today!

COURSE PROGRESS
0%
0 of 40 Modules Solved
COURSE SYLLABUS
40 Lessons
LESSON WORKSPACEAdvanced

SQL Lesson 21: Finding Differences with EXCEPT

Introduction & Core Concept

The EXCEPT operator (known as MINUS in Oracle databases) compares two query result sets and returns strictly the rows from the first (left) query that are completely absent from the second (right) query's results.

SELECT id FROM users
EXCEPT
SELECT user_id FROM orders;
Beginner Analogy: Checking off a Guest List

Think of compiling a guest list for a wedding party:

  • List A contains everyone you invited (Sophia, Rajesh, Aarav, Emma).
  • List B contains the guests who have officially confirmed attendance (Rajesh, Emma).
  • List A EXCEPT List B immediately isolates the invited guests who haven't confirmed yet (Sophia, Aarav).
  • Why & Where We Use It
  • Why We Use It: Pinpointing discrepancies between two datasets without writing complex LEFT JOIN ... WHERE id IS NULL boilerplate code.
  • Where We Use It: Auditing missing accounting offsets, identifying inactive customers, finding SKU inventory catalog discrepancies, and database reconciliation.
  • Real-World Example

    ShopMart auditing team needs to isolate inactive registered user profiles who have never placed a single order so marketing can send them a win-back promotional coupon.

    Best Practices: What to Do & What NOT to Do
  • What to Do: Ensure exact column count and datatype compatibility across both queries, exactly like UNION rules.
  • What NOT to Do: Avoid using EXCEPT on unindexed columns across massive tables, as doing so requires the engine to perform full multi-table sorts to evaluate differences.
  • Syntax & Pro Tips
    SELECT sku FROM catalog EXCEPT SELECT sku FROM sales_ledger;
    Interactive Sandboxed Terminal (Preloaded DB Schema: SHOPMART)
    SQL Query WorkspaceSQLite v3.45 (WASM Mode)
    QUICK INSERT:
    1