Bird
0
0

Find the error in this query:

medium📝 Debug Q7 of 15
SQL - Set Operations
Find the error in this query:
SELECT name FROM employees INTERSECT SELECT department FROM employees;
AColumns in both SELECTs must have the same data type
BINTERSECT cannot be used on the same table
CMissing WHERE clause in one SELECT
DNo error, query is valid
Step-by-Step Solution
Solution:
  1. Step 1: Check column compatibility

    INTERSECT requires both SELECT statements to have the same number and type of columns.
  2. Step 2: Identify mismatch

    Here, 'name' and 'department' likely have different data types, causing error.
  3. Final Answer:

    Columns in both SELECTs must have the same data type -> Option A
  4. Quick Check:

    INTERSECT needs matching column types [OK]
Quick Trick: INTERSECT requires same column types in both queries [OK]
Common Mistakes:
MISTAKES
  • Using different columns with different types
  • Assuming INTERSECT works on any columns
  • Ignoring column count and type rules

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes