The joins multiplied the rows. A join returns one row for every matching pair, so an order with 3 items and 2 payments becomes 6 rows, and SUM(orders.total) counts that order's total 6 times. Whenever you join a table to two or more "many" tables, or join at a finer grain than the number you sum, totals inflate. Aggregate each table to the grain you need first, then join.
See it happen
The order is worth 120, but SUM(total) gives 480.
How to check any query for this
Before trusting a total, count rows at the grain you expect:
SELECT COUNT(*), COUNT(DISTINCT o.order_id)
FROM orders o
JOIN order_items i ON i.order_id = o.order_id
JOIN payments p ON p.order_id = o.order_id;
If the two numbers differ, rows are repeated, and any sum of an order-level column is wrong.
The fix: aggregate, then join
WITH items AS (
SELECT order_id, COUNT(*) AS item_count
FROM order_items GROUP BY order_id
),
paid AS (
SELECT order_id, SUM(amount) AS paid_amount
FROM payments GROUP BY order_id
)
SELECT date_trunc('month', o.created_at) AS month,
SUM(o.total) AS revenue,
SUM(p.paid_amount) AS paid,
SUM(i.item_count) AS items
FROM orders o
LEFT JOIN items i ON i.order_id = o.order_id
LEFT JOIN paid p ON p.order_id = o.order_id
GROUP BY 1;
Each CTE returns one row per order, so the join cannot multiply anything.
Do not patch it with DISTINCT
SUM(DISTINCT total) looks like a fix but silently drops different orders that happen to have the same total. SELECT DISTINCT hides the symptom without fixing the join.
Still not matching finance?
Once the duplication is gone, differences usually come from definitions: refunds and cancellations, tax and shipping, order date versus payment date, and time zone of the month boundary. Write down finance's definition and match it explicitly.
What interviewers want: recognising join fan-out, checking row counts at the expected grain, aggregating before joining, knowing why SUM(DISTINCT) is wrong, and then reconciling definitions.