SQL JOIN Interview Questions
Almost every SQL interview has a join in it. The hard part is rarely the syntax. It is choosing the right join so that rows with no match are kept or dropped on purpose.
These questions practice the joins interviewers ask about most, from combining two tables to finding rows that have no match at all.
Patterns to know
- INNER JOIN vs LEFT JOIN, and what happens to rows with no match
- Anti-joins: LEFT JOIN plus IS NULL to find missing matches
- Self joins for employee and manager pairs
- Joining three or more tables by following the keys
- Joins combined with GROUP BY to count or sum per group
Easy questions
Medium questions
- Medium Top 3 Salaries per Department Identify Top 3 Earners per Department Premium
- Medium Find Missing IDs in a Sequence Detect Missing Order IDs Premium
- Medium Employee and Manager Self Join Employee Reporting Structure Premium
- Medium Customers With No Orders Inactive Customers Report Premium
- Medium Products Frequently Bought Together Frequently Bought Together Premium
- Medium Select Every Other Row Select Every Other Row Premium
- Medium Rows Above Their Group Average Above-Average Track Length per Album Premium
- Medium Best Seller per Category Best Seller in Each Category Premium
- Medium Salary vs Department Average Compare Employee Salary to Department Average Premium
- Medium Join Four Tables Complete Order Detail Report Premium
- Medium Counts and Totals Across Joined Tables Most Prolific Artists Premium
Hard questions
- Hard Monthly User Retention Rate Calculate Monthly Retention Rate Premium
- Hard Median Without a MEDIAN Function Department Salary Median (No MEDIAN Function) Premium
- Hard Unique Categories per Customer per Month Cross-Category Shopping Behavior Premium
- Hard Org Chart Hierarchy With a Recursive CTE Full Organizational Hierarchy Depth Premium
- Hard Find Overlapping Date Ranges Detect Overlapping Room Bookings Premium
- Hard Fuzzy Name Matching Fuzzy Product Name Matching Premium
- Hard Cohort Retention Analysis Monthly Signup Cohort Retention Premium
- Hard Business Metrics in One Query Multi-Metric Executive Dashboard Premium