Most SQL mistakes do not stop the query. The query runs, rows come back, the numbers look plausible, and they answer a different question: an OR without brackets, a join that quietly drops or doubles rows, a NOT IN that meets a NULL, a date range that misses the last day, a rate computed with whole-number division. You only learn to see these by running the query and then checking the answer against something you know.
This is the eighth season of Sabi Logistics’ story, told from the data desk. Emeka, Chidi, Amara, Amaka, Tunde, Ngozi and Zainab bring you questions about their parcels. Every case gives you a company database generated for you alone, loaded into SQLite (a real SQL engine) that runs in your browser, a starter script, and checks that run your SQL in that engine and compare the real rows with the right answers. Most answers are saved as views, so that you build a small, reusable set of questions the way a real team would.
You need nothing installed, and nothing you type can harm anything: the database is rebuilt from scratch every time you press Run.
What you will learn
- Ask precise questions: SELECT, WHERE, ORDER BY, LIMIT, DISTINCT, NULL, and the brackets that AND and OR need.
- Summarise honestly: GROUP BY, HAVING, COUNT DISTINCT, and a rate as a ratio of sums, with exact division.
- Join without losing or doubling: inner and left joins, finding rows with no partner, COALESCE, and sums that join multiplies.
- Use a query inside a query: subqueries, NOT EXISTS, the NOT IN and NULL trap, CTEs and the best row of each group.
- Work with dates: strftime, half-open ranges that include the whole last day, julianday differences, weekdays.
- Rank and compare rows: window functions, ROW_NUMBER against RANK, running totals, LAG.
- Change data safely: INSERT, UPDATE, DELETE, testing the WHERE with a SELECT first, and proving nothing else changed.
- Make the database refuse bad data: primary keys, NOT NULL, foreign keys, CHECK and UNIQUE, and testing that they work.
- Make a slow report fast: indexes, composite indexes, EXPLAIN QUERY PLAN, and what an index costs.
How it works
Each case is a call from someone at Sabi Logistics, a short brief, a database and a script in the SQL lab, a twist and a debrief that says what a senior analyst would do next. Write the SQL, press Run to see the result, press Check my work, and read which tasks are not done yet. When every task passes you get a case reference to submit, and a short write-up to practise explaining your work.
The capstone asks you to design and build a small database of your own, answer real questions from it, and show how you checked every answer.