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.

EasyTechnical
83 practiced

What's the difference between UNION and UNION ALL? Given two same-shaped monthly tables that may contain overlapping rows, write both versions of combining them, and explain when you'd reach for UNION ALL by default and what it costs you to add the dedup pass back in.

EasyTechnical
76 practiced

Explain what a RIGHT JOIN does, then rewrite a RIGHT JOIN query as an equivalent LEFT JOIN by swapping the table order. Why do many teams avoid RIGHT JOIN in their codebase even though it's standard SQL?

EasyTechnical
75 practiced

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).

MediumTechnical
104 practiced

Explain semi-join and anti-join as concepts distinct from a regular INNER or LEFT JOIN: what question each one answers and why. Then write a semi-join with EXISTS to check whether a customer has any qualifying transaction, and explain why this can outperform (and avoid duplicate rows compared to) an INNER JOIN followed by DISTINCT.

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 35 SQL Joins and Set Operations interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.