All roadmaps
SQLBasic → Hard

Joins & GROUP BY Mastery

The two most-tested SQL concepts in every DE interview. Master every join type and every aggregation pattern — from simple counts to multi-table funnel analysis.

25 problems~9h
1
Orders with Customer Namesbasicsql

INNER JOIN basics — match rows from two tables on a foreign key. The join you will write every single day.

2
Employee Count by Departmentbasicsql

GROUP BY + COUNT(*) — the most fundamental aggregation. Know this before anything else.

3
Products Never Orderedbasicsql

LEFT JOIN + WHERE IS NULL — find rows with no match. Three equivalent approaches: LEFT JOIN, NOT IN, NOT EXISTS.

4
Find Duplicate Phone Numbersbasicsql

GROUP BY + HAVING COUNT > 1 — filter after aggregation. HAVING is WHERE for groups.

5
Monthly Sales Totalsbasicsql

GROUP BY on a date column — grouping by month/year is in every reporting query you will write.

6
Total Revenue by Productbasicsql

GROUP BY + SUM() — aggregating a numeric column per group. Foundation for all revenue reporting.

7
Combine Two Tableseasysql

LEFT JOIN to preserve all rows from the left table — when you need every person even without an address.

8
Customers Who Never Ordereasysql

LEFT JOIN + IS NULL vs NOT IN — classic "find what is missing" pattern asked at every company.

9
Employees Earning More Than Managereasysql

Self-join — joining a table to itself on a relationship column. Standard for hierarchy problems.

10
Classes with More Than 5 Studentseasysql

GROUP BY + HAVING with a threshold — practice HAVING with COUNT to filter small groups.

11
Duplicate Emailseasysql

GROUP BY + HAVING COUNT > 1 on a string column — deduplication query pattern for data quality checks.

12
Customers Who Bought All Categorieseasysql

GROUP BY + HAVING COUNT(DISTINCT) = total categories — relational division, a tough but common pattern.

13
Average Order Value by Montheasysql

GROUP BY date truncation + AVG() — monthly bucketing with date functions alongside aggregation.

14
Monthly Transactionsmediumsql

Conditional aggregation: SUM(CASE WHEN ...) — pivot-style counts/sums in a single GROUP BY query.

15
Friend Requests Acceptance Ratemediumsql

Two-table ratio: COUNT from join / COUNT from base — funnel and conversion rate calculation pattern.

16
Department Highest Salarymediumsql

JOIN to a subquery returning MAX per group — the classic correlated subquery vs window function trade-off.

17
Managers with At Least 5 Direct Reportsmediumsql

Self-join + GROUP BY + HAVING — joining the same table to aggregate subordinates per manager.

18
Customer Lifetime Valuemediumsql

Multi-table JOIN + GROUP BY + multiple aggregations — the most common DE business metric query.

19
Products Bought Togethermediumsql

Self-join on order_id + GROUP BY pair + HAVING — market basket analysis with a self-join.

20
Cross-Sell Product Pairsmediumsql

Self-join + GROUP BY + COUNT — finding co-occurrence patterns. Harder variant of products-bought-together.

21
Trips and Usershardsql

Multi-join + date filter + conditional aggregation in one query — the classic hard Uber/Lyft problem.

22
Active User Retentionhardsql

Self-join on user_id across two consecutive months — retention analysis without window functions.

23
Multi-Step Conversion Funnelhardsql

Multiple LEFT JOINs + conditional COUNT — building a funnel from raw event data, asked at every product company.

24
Market Basket Association Ruleshardsql

Self-join + GROUP BY + HAVING + percentage — full association rule mining with support and confidence.

25
Employee Hierarchy Depthhardsql

Recursive CTE — self-referential join to traverse a tree. The advanced join pattern asked at senior-level rounds.