Interview preparation
Answers that explain the decision, the reason, the evidence and the limit — not one-liners.
Choose a question
Swipe to browseInterview answer
01 / 26
Why can a JOIN silently inflate your totals?
Joining two child tables of the same parent multiplies rows.
One order line joined to two payment rows becomes two rows, so revenue doubles.
State the grain of every table and aggregate to a shared grain before joining.
Visual walkthrough
join fan-out
| O101 | line 1 | ₹300 |
| O101 | P101 | FAILED |
| O101 | P102 | SUCCESS |
| line 1 | P101 | ₹300 |
| line 1 | P102 | ₹300 |
SUM(line_revenue)₹0
Wrong: the single ₹300 line is counted once per payment attempt.
Fix: aggregate payments to one row per order first
line 1 · paid ✓ · ₹300 → SUM = ₹300
