Describe set operations like UNION, INTERSECT, and EXCEPT

SQL
Medium
115.9K views

This question tests set theory application in SQL. It evaluates merging and filtering logic.

Why Interviewers Ask This

Set operations are powerful for combining datasets. Interviewers check if you know when to merge, intersect, or subtract results.

How to Answer This Question

Define UNION (merge unique), INTERSECT (common), and EXCEPT (difference). Mention requirement for compatible columns.

Key Points to Cover

  • UNION merges distinct
  • INTERSECT finds common
  • EXCEPT finds difference
  • Compatible columns required

Sample Answer

UNION, INTERSECT, and EXCEPT are set operations that combine results from two queries. UNION returns the distinct union of both sets. INTERSECT returns only rows present in both. EXCEPT returns rows in the first set but not the second.

Common Mistakes to Avoid

  • Using UNION ALL for intersection
  • Ignoring column compatibility
  • Confusing EXCEPT with MINUS

Practice This Question with AI

Answer this question orally or via text and get instant AI-powered feedback on your response quality, structure, and delivery.

Start Practicing

Related Interview Questions

Browse all 49 SQL questions