Bird
0
0

Given two tables:

medium📝 query result Q4 of 15
PostgreSQL - Set Operations and Advanced Queries
Given two tables:
tableA(id) VALUES (5), (6), (7);
tableB(id) VALUES (6), (7), (8);
What will be the output of this query?
SELECT id FROM tableA EXCEPT SELECT id FROM tableB;
A(8)
B(6), (7)
C(5)
D(5), (8)
Step-by-Step Solution
Solution:
  1. Step 1: Understand EXCEPT

    The EXCEPT operation returns rows from the first query that are not present in the second.
  2. Step 2: Apply to given data

    tableA has (5), (6), (7); tableB has (6), (7), (8). Rows (6) and (7) are in both, so they are excluded.
  3. Final Answer:

    (5) -> Option C
  4. Quick Check:

    Verify rows unique to first table [OK]
Quick Trick: EXCEPT returns rows only in first query [OK]
Common Mistakes:
  • Confusing EXCEPT with INTERSECT
  • Including rows from second table
  • Assuming EXCEPT returns duplicates

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes