ACCTG 6155 · Week 3 · Why an INNER JOIN can quietly lose money in cash application
lockbox_payments table to the invoices table
on invoice_id. But two of the payments reference invoices that
do not exist in our system, the lockbox mis-coded the checks. Watch what
each join does with that gap.
| payment_id | invoice_id | amount |
|---|
| invoice_id | customer_name | amount_due |
|---|
invoices table has four rows, and only three of them match
a payment. Two payments, PAY-9004 and PAY-9006,
point at invoices (INV-2026-900000,
INV-2026-900001) that nobody can find. One invoice,
INV-2026-0061, has no payment at all. Those are two different
problems, and which one you can see depends on how you write the join.
These rows are in the database. They are not in the result above.
| table | row | why it is not in the result | amount |
|---|
In real cash-app work, the fix for a dropped row is to track down the missing invoice. It might be in another AR system, on a colleague's desk, or one phone call away at the customer or the lockbox bank. Simulate finding them and watch the INNER JOIN stop losing payments.
Then flip the question. Locating those two invoices closes the cash gap.
It does nothing for INV-2026-0061, which nobody has paid.
lockbox_payments first and you find cash
that cannot be applied. Put invoices first and you find an
invoice nobody paid. Same keyword, and neither direction sees the
other's problem.INV-2026-0011 was paid twice, so four invoices come back
as five rows. Check what your join did to the row count, every time.