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.

MediumTechnical
76 practiced

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.

EasyTechnical
70 practiced

Rewrite this old-style comma-separated join (FROM a, b WHERE a.id = b.a_id AND ...) into explicit JOIN ... ON syntax, and explain the practical reasons explicit joins are preferred in production code, including what silently goes wrong if someone forgets a WHERE condition in the old style.

EasyTechnical
63 practiced

Given an employees table that references itself for a manager relationship (employee_id, name, manager_id), write a query that returns each employee alongside their manager's name, showing NULL (or an explicit 'no manager') for anyone at the top of the org. Explain why a self-join is the natural tool here, and how you'd extend the same pattern one more level up (manager's manager) or decide you need a recursive CTE instead.

EasyTechnical
58 practiced

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.

EasyTechnical
77 practiced

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.

Unlock Full Question Bank

Get access to all 10 SQL Joins and Set Operations interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.