Skip to content
RED SAGSkills
medium10 pts · first answer countssqljoinsdata-quality

Revenue doubled after a join

You join orders to order_items and then SUM(orders.total) by month. The revenue is much higher than finance reports. What is the most likely cause?

SELECT DATE_TRUNC('month', o.created_at) AS m,
       SUM(o.total) AS revenue
FROM orders o
JOIN order_items i ON i.order_id = o.id
GROUP BY 1
Choose one answer