Bird
0
0

Consider these tables:

medium📝 query result Q5 of 15
SQL - Set Operations
Consider these tables:
employees:
id
101
102
103

managers:
id
102
104

What does this query return?
SELECT id FROM employees EXCEPT SELECT id FROM managers;
A104
B101, 103
C101, 102, 103, 104
D102, 104
Step-by-Step Solution
Solution:
  1. Step 1: List employee ids

    Employees have ids 101, 102, 103.
  2. Step 2: List manager ids

    Managers have ids 102, 104.
  3. Step 3: Find employees not managers

    Ids 101 and 103 are in employees but not in managers.
  4. Final Answer:

    101, 103 -> Option B
  5. Quick Check:

    EXCEPT filters out common ids [OK]
Quick Trick: EXCEPT filters out common rows from first query [OK]
Common Mistakes:
MISTAKES
  • Including ids only in second table
  • Listing all ids from both tables
  • Confusing EXCEPT with UNION

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes