InterviewStack.io LogoInterviewStack.io

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.

MediumTechnical
78 practiced

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.

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
62 practiced

What does a CROSS JOIN produce? Given two small tables like colors(color) and sizes(size), write the query that generates every combination for a product feed, and show a handful of example input/output rows.

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

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.