SQL Training — Phase 1
How this works
Below you'll find short explanations, worked examples, and then the exercises. Every exercise has a real SQL console: write your query on the left, click Run to see the result on the right, and click Submit when you're confident — it will tell you if it's correct and save your progress automatically.
Grading note: grading compares the values your query returns, not row order. Column order does matter — return columns in the order the question implies. If you're unsure, run it first and eyeball the result before submitting.
Reference: the dataset
This is a simplified finance dataset — invoices, vendors, tax codes and cost centers — shaped like the kind of data you already work with in audit and tax, just modernized.
| Table | Key columns |
|---|---|
invoices | invoice_id, vendor_id, cost_center_id, invoice_date, due_date, tax_code, net_amount, tax_amount, total_amount, status |
vendors | vendor_id, vendor_name, country, vendor_category, risk_flag |
tax_codes | tax_code, description, rate |
cost_centers | cost_center_id, cost_center_name, department |
Part A — SELECT, filtering, sorting
This is the most basic — and most used — shape of SQL: picking rows out of a table based on a condition, and putting them in an order that makes sense. Think of it as the SQL version of applying a filter and a sort in a spreadsheet.
Worked example — try running this one first, it's pre-filled:
Exercises 1–6
Part B — GROUP BY and aggregations
Grouping answers questions like "how much per status" or "how many per vendor" — exactly what you already do with pivot tables in Excel, just expressed as a query.
Exercises 7–12
Part C — Interview-style questions
These use the same skills as Parts A and B, but framed the way interviewers actually ask them in 2026 Data Analyst screens — duplicate detection, "Nth highest value," and open business scenarios. Recognizing the shape of the question matters as much as the SQL itself.
Self-check before the weekly review
Before the check-in, you should be able to, without looking anything up: explain the difference between WHERE and HAVING (see Figure 4 above); write a GROUP BY with an aggregate from scratch; and explain why the "second-highest" question needs a different approach than just skipping one row with LIMIT/OFFSET. If any of this feels shaky, that's normal for week 1 — flag it.