Describe set operations like UNION, INTERSECT, and EXCEPT
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.
Related Interview Questions
Describe a PRIMARY KEY and how it differs from a UNIQUE key
Medium
What is ER model in the DBMS?
Medium
FlipkartWhat is the difference between LIKE and equals operators in SQL?
Easy
TCSWhat is the difference between UNION and UNION ALL?
Easy
What is Join and explain its types?
Medium
FlipkartWhat is the ER model in DBMS?
Easy
Flipkart