SQL Joins and Set Operations Questions
Combining data across multiple tables using inner, outer, cross, and self joins, plus set operations (UNION, INTERSECT, EXCEPT). Covers join-key selection, fan-out and row-multiplication pitfalls, merge strategies, and integrating data from disparate sources. A high-frequency interview surface for anyone who queries relational data.
Optimizer hints (forcing a join order, an index, or a specific join algorithm) exist in most major databases under different names. When is reaching for a hint the right call for a critical query, and what maintenance risk does relying on hints introduce as the underlying data or version changes? Give the guardrails you would put in place before shipping one.
What's the difference between an equi-join and a non-equi join? Give a concrete example where a non-equi join is the right tool, for example matching a transaction amount to the pricing tier it falls into, and talk through the indexing and performance considerations that change once you move off plain equality.
How does NULL behave in a join's equality condition, and separately in UNION/INTERSECT/EXCEPT comparisons? Build a small two-table example where a NULL join key causes a row to silently drop out of an INNER JOIN, show how a LEFT JOIN's NULLs can distort a downstream SUM or AVG if you're not careful, and demonstrate how COALESCE can defend against both.
Joins combine tables horizontally (adding columns); set operations combine result sets vertically (stacking or comparing rows). Give two concrete examples where the right tool is a set operation and two where it's a join, and explain what goes wrong with duplicate and NULL handling if you reach for the wrong shape.
When would you restructure a deeply nested, hard-to-review multi-join query into a series of CTEs instead of leaving it as nested subqueries? Take a query chaining several joins and rewrite it as staged CTEs, explaining how you decided where to break it up and any performance caveats worth knowing about.
Unlock Full Question Bank
Get access to all 42 SQL Joins and Set Operations interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.