SQL for data analysts
46 levels in 8 chapters
Learn SQL the way analysts use it: real tickets from colleagues, answered with queries on a full store database, right in your browser.
By the end you can filter, join, group and rank a real company database, and write the CTEs and window functions interviewers ask about. Every level is open; the path only suggests an order.
Chapter 1 · 5 levels
SELECT basics
- Look at the product catalogNot started, difficulty 1 of 5 Next up
- Pick only the columns you needNot started, difficulty 1 of 5 Next up
- Compute margin per productNot started, difficulty 2 of 5 Next up
- List the category treeNot started, difficulty 1 of 5 Next up
- Boss Boss: catalog snapshotNot started, boss, 3 steps, difficulty 2 of 5 Next up
Chapter 2 · 6 levels
Filtering rows
- Find refunded ordersNot started, difficulty 1 of 5 Next up
- Gift ideas under $50Not started, difficulty 2 of 5 Next up
- Orders from March 2024Not started, difficulty 2 of 5 Next up
- Find Gmail customersNot started, difficulty 2 of 5 Next up
- The NULL comparison trapNot started, quiz, difficulty 2 of 5 Next up
- Boss Boss: data quality sweepNot started, boss, 3 steps, difficulty 3 of 5 Next up
Chapter 3 · 5 levels
Sorting and limits
- Price list, most expensive firstNot started, difficulty 1 of 5 Next up
- The 10 most recent ordersNot started, difficulty 2 of 5 Next up
- Page two of the price listNot started, difficulty 2 of 5 Next up
- Missing costs on topNot started, difficulty 2 of 5 Next up
- Boss Boss: homepage merchandising listsNot started, boss, 3 steps, difficulty 3 of 5 Next up
Chapter 4 · 6 levels
Aggregates and GROUP BY
- How many customers came from referrals?Not started, difficulty 2 of 5 Next up
- Total units and revenueNot started, difficulty 2 of 5 Next up
- Orders by channel and statusNot started, difficulty 2 of 5 Next up
- Our most loyal customersNot started, difficulty 3 of 5 Next up
- Why does this query fail?Not started, quiz, difficulty 3 of 5 Next up
- Boss Boss: performance snapshotNot started, boss, 3 steps, difficulty 3 of 5 Next up
Chapter 5 · 6 levels
JOINs
- Revenue by categoryNot started, difficulty 2 of 5 Next up
- Customers who never orderedNot started, difficulty 3 of 5 Next up
- App orders per business customerNot started, difficulty 3 of 5 Next up
- Lines per order without double countingNot started, difficulty 4 of 5 Next up
- Who reports to whomNot started, difficulty 3 of 5 Next up
- Boss Boss: category scorecardNot started, boss, 3 steps, difficulty 4 of 5 Next up
Chapter 6 · 6 levels
CASE, dates and strings
- Products by price bandNot started, difficulty 2 of 5 Next up
- Cancellation rate by channelNot started, difficulty 3 of 5 Next up
- Monthly revenue for 2025Not started, difficulty 3 of 5 Next up
- How long until items come back?Not started, difficulty 3 of 5 Next up
- Customers by state, cleaned upNot started, difficulty 2 of 5 Next up
- Boss Boss: customer base profileNot started, boss, 3 steps, difficulty 4 of 5 Next up
Chapter 7 · 6 levels
Subqueries and CTEs
- Products priced above averageNot started, difficulty 3 of 5 Next up
- Customers who returned somethingNot started, difficulty 3 of 5 Next up
- Customer lifetime valueNot started, difficulty 3 of 5 Next up
- Shipping and merchandise revenue per channelNot started, difficulty 4 of 5 Next up
- Find duplicate customer recordsNot started, difficulty 3 of 5 Next up
- Boss Boss: first orders and repeat purchasesNot started, boss, 3 steps, difficulty 5 of 5 Next up
Chapter 8 · 6 levels
Window functions
- Top 3 products in every categoryNot started, difficulty 4 of 5 Next up
- ROW_NUMBER vs RANK vs DENSE_RANKNot started, difficulty 3 of 5 Next up
- Year-to-date revenueNot started, difficulty 4 of 5 Next up
- Month-over-month growthNot started, difficulty 4 of 5 Next up
- 7-day moving average of ordersNot started, difficulty 4 of 5 Next up
- Boss Boss: cohort retentionNot started, boss, 3 steps, difficulty 5 of 5 Next up

Jessica Turner · Merchandising Manager
"Welcome aboard! Before we get into anything fancy, could you pull up the whole product catalog so you can see what we sell?"
Light the next lantern