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.
Walk me through INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL OUTER JOIN, and CROSS JOIN: what each one returns, how row counts change relative to the inputs, and how unmatched rows show up as NULLs. Ground it with a short two-table example (say customers and orders).
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.
Explain what INTERSECT and EXCEPT (or MINUS) do. Given two same-shaped snapshots of the same population (say two years of customer IDs), write queries that find customers present in both and customers present in one but not the other, and note how NULLs and duplicate rows affect the result.
Two tables you're joining share a column name (say both have an 'id' or 'created_at'). Show how to write the SELECT with table aliases and explicit column aliases so the result set has clear, unambiguous names, and explain what silently goes wrong for a downstream consumer (a BI tool, a script) if you don't.
Unlock Full Question Bank
Get access to all 10 SQL Joins and Set Operations interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.