Skip to content
RED SAG Skills
mediumStudy question · answer published in SQL interview questions, so no pointssqljoinsdata-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

Discussion 0

Join free to post in the discussion.

Related questions