How do I write SQL, and check the AI's SQL?
Learn SELECT, WHERE, GROUP BY and JOIN on a real dataset, then check AI-written queries on small examples where you already know the answer.
SQL is the language for asking a database questions. A query names the columns you want, the table they come from, which rows to keep and how to sort them. From there you add summaries (GROUP BY with COUNT, SUM or AVG), combine tables that share an id (JOIN) and change data (INSERT, UPDATE, DELETE).
AI writes SQL quickly, and its mistakes are quiet: the query runs, but the numbers are wrong. Check for these:
- Joins that double count, such as adding up order totals after joining each order to its items.
- An inner JOIN where a LEFT JOIN was needed, which silently drops rows with no match, like customers with zero orders.
- NULL, the value for "missing", which doesn't behave like a normal value in comparisons.
- UPDATE or DELETE without a precise WHERE clause.
- Values pasted into the query text instead of passed as parameters, which opens the door to SQL injection.
The habit that catches most of these: run the query on a few rows you can count by hand, and compare its totals with a simpler query.
Vumbli's Databases & SQL Deep Dive track goes from "Your first questions to a database" to window functions and indexes on a realistic online store, includes fixing a report that double counts, and ends with a monthly analytics report.
Start with these missions
- Your first questions to a database (Databases & SQL Deep Dive)
- Summaries with GROUP BY and HAVING (Databases & SQL Deep Dive)
- JOIN: combine tables by a shared id (Databases & SQL Deep Dive)
Tracks that teach it
More questions, answered by building