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

  1. Easy Departments With More Than 5 Employees Large Department Report Free
  2. Easy Count Rows per Group Course Enrollment Numbers Free
  3. Easy Total Revenue per Customer Customer Lifetime Value Free
  4. Easy Longest Item per Group Each Artist's Longest Song Free

Medium questions

  1. Medium Top 3 Salaries per Department Identify Top 3 Earners per Department Premium
  2. Medium Find Missing IDs in a Sequence Detect Missing Order IDs Premium
  3. Medium Employee and Manager Self Join Employee Reporting Structure Premium
  4. Medium Customers With No Orders Inactive Customers Report Premium
  5. Medium Products Frequently Bought Together Frequently Bought Together Premium
  6. Medium Select Every Other Row Select Every Other Row Premium
  7. Medium Rows Above Their Group Average Above-Average Track Length per Album Premium
  8. Medium Best Seller per Category Best Seller in Each Category Premium
  9. Medium Salary vs Department Average Compare Employee Salary to Department Average Premium
  10. Medium Join Four Tables Complete Order Detail Report Premium
  11. Medium Counts and Totals Across Joined Tables Most Prolific Artists Premium

Hard questions

  1. Hard Monthly User Retention Rate Calculate Monthly Retention Rate Premium
  2. Hard Median Without a MEDIAN Function Department Salary Median (No MEDIAN Function) Premium
  3. Hard Unique Categories per Customer per Month Cross-Category Shopping Behavior Premium
  4. Hard Org Chart Hierarchy With a Recursive CTE Full Organizational Hierarchy Depth Premium
  5. Hard Find Overlapping Date Ranges Detect Overlapping Room Bookings Premium
  6. Hard Fuzzy Name Matching Fuzzy Product Name Matching Premium
  7. Hard Cohort Retention Analysis Monthly Signup Cohort Retention Premium
  8. Hard Business Metrics in One Query Multi-Metric Executive Dashboard Premium

More SQL interview topics