SQL JOIN Fan-Out Silently Doubled Refund Totals in Store Report
A developer's SQL query ran without errors, yet one customer's refund total came out at $60 when only $30 had been refunded. The cause was a JOIN that matched one customer against multiple rows, so the results multiplied rather than staying one row per customer. The article reproduces the issue with a small sample dataset of customers, orders, and refunds for an online store. It explains that a JOIN's result grain can change when it links to the many side of a one-to-many relationship. The author notes that the mistake comes from forgetting that multiplication occurred, not from a syntax problem.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in