SQL online course

Joins

Inner, left, and the key-matching mistakes that duplicate rows.

A join combines rows from two tables using a condition, usually a foreign key. If the condition is wrong, you get a cartesian mess: every person attached to every order.

When a report “suddenly doubles,” look for a one-to-many you forgot about. Aggregate first in a subquery, or join to a table that is truly one row per key.