The query ran. The number is wrong.
This one is meant to count discounted orders for each of the shop's 40 customers, zeros included. Run it and look at how many rows come back.
SELECT c.name, COUNT(o.id) AS discounted_orders
FROM customers c
LEFT JOIN orders o ON o.customer_id = c.id
WHERE o.discount >= 0.1
GROUP BY c.name
ORDER BY discounted_orders;| name | discounted_orders |
|---|---|
| Bram Haddad | 1 |
| Hana Kowalski | 1 |
| Kofi Reyes | 1 |
| Leilani Fonseca | 1 |
| Mirela Dubois | 1 |
| Noor Lindqvist | 1 |
30 rows, first 6 shown
A level means you did it
The tutor can propose that you got something right. It can't raise your level. The server counts your passes, and a query exercise is marked by comparing your actual result with the correct one.
| Level | Meaning | To earn it |
|---|---|---|
| 0 | Haven't met it | Where most people start on something new |
| 1 | Heard of it | Two passes at the level below, one from unaided recall. A hint downgrades the pass. Pressing "Just tell me" earns none. |
| 2 | Can follow along | |
| 3 | Can do it with help | |
| 4 | Can do it alone | |
| 5 | Could teach it | The same, plus an edge case you handled and an explanation someone could learn from |
How a session goes
- Placement
About five questions, easy to hard, with no teaching. You get a map of eight skills, from filtering through window functions.
- One question at a time
Get one wrong and the next question is narrower. It's built to contradict what you just said, so you find the error yourself.
- Real queries
Exercises run against a bike shop's database in your browser. It has the NULLs, ties and orphaned rows that break naive queries.
- Unannounced review
Old skills come back with no warning. Fail one and the level drops.
- Final assessment
When every skill reaches level 4, you sit a mixed exam with no hints and one problem that needs several skills at once.
Guides
- Why your LEFT JOIN acts like an INNER JOIN2 min
- Why COUNT and SUM are too high after a JOIN2 min
- Why NOT IN returns nothing when the list contains NULL2 min
- WHERE vs HAVING, and when the choice changes your answer2 min
- ROW_NUMBER vs RANK vs DENSE_RANK2 min
- How to get the top N rows per group in SQL2 min
- Running totals in SQL, and the ROWS vs RANGE trap2 min
- Finding consecutive days in SQL (gaps and islands)2 min
- SQL interview questions for data analysts, with runnable answers2 min
Questions
- Why not ask ChatGPT?
- You can, and it will fix your query. That's useful at work and bad for an interview, where nobody is there to fix it. Wrong Join withholds the answer, runs what you write, and keeps a record of what you can do unaided.
- Is the tutor an AI?
- Yes. It's a large language model, and it can make mistakes. Query results come from a real SQL engine, so whether your query is correct doesn't rest on the model's opinion.
- Which SQL does it teach?
- Standard SQL, run on SQLite. Joins, aggregation, CTEs and window functions carry straight over to Postgres, MySQL, BigQuery and Snowflake. Date functions differ between engines, and the tutor will say so when it matters.
- What does it cost?
- Eight tutor turns with no account, twenty a day with one, or $12 a month for Pro. See pricing.