All work

Case study

The team multiplier: teaching people to check their SQL

A small example I used to teach a check for SQL joins that multiply rows.

At a glance

Years as a maths tutor
6
Role
SQL knowledge sharing, Carsome
Period
2022 – 2023 at Carsome
Tools
SQL · Data modelling
The story

Problem

A SQL query can run and still give you the wrong total. Join two tables that each have several rows per car and the result can multiply rows before anyone notices.

Decision

Start with one question. What is one row supposed to represent? Six years of tutoring maths taught me to put a small example in front of people so they can work the answer out themselves.

Build

In a Carsome SQL knowledge-sharing session, the checks were concrete. Find the columns that uniquely identify the row you need, count how many matches each side of a join can produce, and summarise each table at the required level before you join them.

Carsome’s Data Science & Advanced Analytics team used a different kind of example in its B2C Personas work. The team clustered shoppers into seven groups using signals such as the prices and types of cars they viewed. One group browsed far more models than the others. That difference gives the car finder a practical question to test. What would help someone who’s still exploring narrow their options?

Metric moved

Take a car with three status changes and two appointments. Join the two histories directly on the car and you get six rows. Summarise each history to one row per car first and the join gives you one row, with the two counts intact. You can check the result by hand before trusting the query on a full dataset.

How the work moved
  1. Start with a query that is difficult to explain.
  2. Check the join keys and where rows multiply.
  3. Teach the reasoning using a worked example.

In one line

I want someone to leave a session with a check they can use on the next query they write.