Your SQL learning path
Each module builds on the one before it. Work through the drills in order, or jump to any you like.
How you'll learn
1Read a 30-second concept
Each drill opens with one idea and a tiny example on different data, so the answer isn't handed to you.
2Write the query yourself
A real business question and the exact result wanted. You type every query: that's where it sticks.
3Get corrected instantly
Wrong rows light up red, and the feedback names the likely mistake, like using OR instead of AND or = NULL.
4Hints, then the solution
Stuck? Reveal hints one at a time. After 3 tries the solution unlocks; read it, then type it in yourself.
5Review until it sticks
Solved drills come back for review: in a few days if they were easy, tomorrow if you struggled. Each clean solve doubles the gap.
- 0/10
Module 1
The Basics
Filter, sort and summarize a single table: the 80% of SQL you'll write every day.
- 1. Customer directorySELECT · ORDER BYUp next
- 2. Active Canadian customersWHERE · AND
- 3. Customers with a .ca emailLIKE · wildcards
- 4. Three biggest ordersORDER BY · LIMIT
- 5. Revenue per customerCOUNT · SUM · GROUP BY
- 6. Countries with active customersSELECT DISTINCT
- 7. First-week shipmentsIN · BETWEEN
- 8. Salary bandsCASE WHEN
- 9. Filling in missing managersNULL · COALESCE
- 10. Weekend loginsEXTRACT · day of week
- 0/10
Module 2
Intermediate Joins
Combine tables without losing rows, and filter on aggregates with HAVING.
- 11. Orders with customer namesINNER JOIN
- 12. Every user and their planINNER JOIN vs LEFT JOIN
- 13. Users who never subscribedLEFT JOIN · IS NULL
- 14. Revenue by countryJOIN + GROUP BY
- 15. High-value repeat buyersGROUP BY · HAVING
- 16. Plan behind each purchaseThree-table JOIN
- 17. Order count, including zeroLEFT JOIN · COUNT(col) vs COUNT(*)
- 18. Customers with a big orderIN (subquery) · EXISTS
- 19. Purchase date for every userLEFT JOIN · filter in ON vs WHERE
- 20. Total touchpoints per userUNION vs UNION ALL
- 0/25
Module 3
Interview Drills
Window functions, CTEs and the patterns FAANG and fintech interviewers ask about.
- 21. Top 3 earners per departmentWindow functions · DENSE_RANK()
- 22. Running revenue totalSUM() OVER · running totalsPro
- 23. Consecutive-day loginsLAG() · date arithmeticPro
- 24. Paid above department averageAVG() OVER · compare to groupPro
- 25. Days to first purchaseCTE · MIN · date mathPro
- 26. Earning more than their managerSelf-joinPro
- 27. Duplicate card chargesGROUP BY · HAVING to find duplicatesPro
- 28. Monthly spendto_char · GROUP BY monthPro
- 29. Spend by category, one row per accountPivot with FILTER / CASEPro
- 30. Share of total spendSUM() OVER () · percent of totalPro
- 31. Signup-to-purchase funnelCOUNT(DISTINCT) · funnel stepsPro
- 32. Fast convertersJOIN + date differencePro
- 33. Month-over-month growthCTE + LAG · growth ratePro
- 34. Median salary by departmentPERCENTILE_CONT · ordered-set aggregatesPro
- 35. Longest login streakGaps and islandsPro
- 36. Refund rate per customerConditional aggregation · FILTERPro
- 37. Days until next orderLEAD() · PARTITION BYPro
- 38. Each customer's first orderDISTINCT ON · first row per groupPro
- 39. Third-highest salary per departmentNth highest · DENSE_RANK() vs ROW_NUMBER()Pro
- 40. Largest charge per accountROW_NUMBER() · deterministic tie-breakerPro
- 41. Salary quartilesNTILE() · bucketsPro
- 42. Active in every monthCOUNT(DISTINCT month) · relational divisionPro
- 43. 3-transaction moving averageWindow frames · ROWS vs RANGEPro
- 44. First vs latest order valueFIRST_VALUE · LAST_VALUE · frame trapPro
- 45. Org chart with recursive CTEWITH RECURSIVE · hierarchiesPro
- 0/15
Module 4
Analytics Patterns
Retention cohorts, sessionization, gaps and islands, attribution: the real-world analysis senior interviews test.
- 46. Order value histogramFLOOR · histogram bucketsPro
- 47. Current plan per userDISTINCT ON · latest row per keyPro
- 48. Customer share of country revenueSUM() OVER (PARTITION BY) · percent of groupPro
- 49. Daily active users, zero days includedgenerate_series · LEFT JOIN · filling date gapsPro
- 50. Year-over-year growth by quarterSelf-join on period · YoY %Pro
- 51. Plan at time of purchaseAs-of join · JOIN LATERALPro
- 52. 7-day moving average revenueRANGE window frame · calendar moving averagePro
- 53. DAU/MAU stickinessDistinct user-days · days in month · ratiosPro
- 54. Month-1 retention by signup cohortCohorts · date_trunc · LEFT JOINPro
- 55. Monthly churn rateAnti-join across months · churnPro
- 56. New vs returning usersFirst-seen month · running distinct countPro
- 57. First-touch vs last-touch attributionROW_NUMBER both ways · attributionPro
- 58. Activity streaks as date rangesGaps and islands · duplicate daysPro
- 59. Sessions from raw pageviewsLAG · running SUM · sessionizationPro
- 60. Pricing to checkout within an hourFunnel with a time window · range joinPro
Today's free interview drill
One Pro drill is free for everyone each day. Open today's, or get it by email: