The billing dashboard reports paid invoices by the month they were issued. Finance reports cash by the month it was collected. Over three years the two totals are identical, yet the monthly figures rarely match, and finance wants the difference for the second half of 2025 explained before the year closes.
Return month (YYYY-MM), invoiced_paid (amount_due of invoices with invoice_status paid, by the month of invoice_date), collected (amount of payments with payment_status succeeded, by the month of attempted_at), difference (collected minus invoiced_paid), carried_in (the part of collected that paid an invoice dated in an earlier month), and carried_out (the part of invoiced_paid that was collected in a later month). Show the six months from 2025-07 to 2025-12, with 0 where a month has nothing on one side. Round amounts to 2 decimals and order by month.
Create a free account to save your progress and reveal the worked answer for this free exercise. The complete practice library is available with Practice Pass or Mastery.