30/30
Part 5 of 5 · The worked exampleCheck yourself
Check yourself
5 questions
  1. 1.After joining orders to their item lines, a teammate patches the inflated numbers with COUNT(DISTINCT o.order_id) and SUM(DISTINCT o.total_cents). What's still wrong?

  2. 2.Every customer and their March order count, 0 for none. You move the date filter from WHERE into the LEFT JOIN's ON clause but keep COUNT(*). What does a customer with no orders get?

  3. 3.SELECT code FROM promos WHERE code NOT IN (SELECT promo FROM orders) returns nothing, though one code was never used. Why?

  4. 4.Two of five orders used a promo. In SQLite, what does SELECT COUNT(promo) / COUNT(*) * 1.0 FROM orders return?

  5. 5.placed_at holds text like '2026-03-31 20:30'. Which March orders does WHERE placed_at BETWEEN '2026-03-01' AND '2026-03-31' miss?

That's the lesson.
Now the problem this lesson builds to: 15 Explain and fix AI-generated SQLPractice it