Bird
0
0

Find the issue in this query:

medium📝 Debug Q7 of 15
SQL - Set Operations
Find the issue in this query:
SELECT id FROM table1 EXCEPT SELECT name FROM table2;
AColumn names must match in both SELECT statements
BSELECT statements must have same number of columns and compatible types
CEXCEPT requires WHERE clause
DEXCEPT cannot compare different tables
Step-by-Step Solution
Solution:
  1. Step 1: Check column compatibility

    EXCEPT requires both SELECTs to have same number of columns with compatible data types.
  2. Step 2: Identify mismatch

    First SELECT uses 'id', second uses 'name' which may differ in type or meaning.
  3. Final Answer:

    SELECT statements must have same number of columns and compatible types -> Option B
  4. Quick Check:

    EXCEPT needs matching columns and types [OK]
Quick Trick: EXCEPT requires matching columns and data types [OK]
Common Mistakes:
MISTAKES
  • Assuming column names must be identical
  • Ignoring data type compatibility
  • Using different number of columns

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes