Skip to content
We areTOP 1%
DBMS & SQL · Intermediate · Topic 2 of 4

SQL: Joins

9 questions.
Your progress0%
1st Visit
0/9
2nd Visit
0/9
Revise
0/9

Overview

A join combines rows from two tables using a related column, usually a foreign key matching a primary key. INNER JOIN keeps only matching pairs; LEFT JOIN keeps every row of the left table and fills the missing right side with NULL; CROSS JOIN pairs every row with every row; and a self join compares rows within one table, such as employees and their managers. Watch the row count: joining on a non-unique column multiplies rows and can inflate sums. Signals include data spread across several tables, "including those with no orders" (left join) and "customers who never ordered" (left join with IS NULL).

SELECT c.name, COUNT(o.id) AS orders
FROM customers c
LEFT JOIN orders o ON o.customer_id = c.id
GROUP BY c.id, c.name;   -- customers with no orders show 0

Questions

SQL: Joins questions
#ProblemPlatformDifficultyOpen1st1st Visit2nd2nd VisitRevRevise
1What are the different types of joins in SQL?
EasyConcept
ConceptEasy Read the answer to What are the different types of joins in SQL?
2What is the difference between UNION and UNION ALL, and how is UNION different from a JOIN?
EasyConcept
ConceptEasy Read the answer to What is the difference between UNION and UNION ALL, and how is UNION different from a JOIN?
3Combine Two TablesLeetCodeEasy Solve Combine Two Tables on LeetCode (opens in a new tab)
4Employees Earning More Than Their ManagersLeetCodeEasy Solve Employees Earning More Than Their Managers on LeetCode (opens in a new tab)
5Customer Who Visited but Did Not Make Any TransactionsLeetCodeEasy Solve Customer Who Visited but Did Not Make Any Transactions on LeetCode (opens in a new tab)
6Students and ExaminationsLeetCodeEasy Solve Students and Examinations on LeetCode (opens in a new tab)
7What is the difference between an equi join, a natural join, a theta join and a self join?
MediumConcept
ConceptMedium Read the answer to What is the difference between an equi join, a natural join, a theta join and a self join?
8What is a correlated subquery, and when would you use a join instead of a subquery?
MediumConcept
ConceptMedium Read the answer to What is a correlated subquery, and when would you use a join instead of a subquery?
9Managers with at Least 5 Direct ReportsLeetCodeMedium Solve Managers with at Least 5 Direct Reports on LeetCode (opens in a new tab)

Sign in to track your progress

Your checkboxes, streak and activity heatmap are saved to your account and sync across devices. It is free.
Sign in with email

New here? Create an account