The monthly_orders table contains a row for each customer-month with recorded activity. Write a query to report gaps between consecutive recorded months for the same customer.
Return the earlier month as gap_after, the next recorded month as gap_before, and the number of absent calendar months between them as months_missing. Include only gaps containing at least one missing month.
A recorded month with zero orders is present, not missing. Do not report an open-ended gap after a customer’s final recorded month.
Ordering: Sort by customer_id, then gap_after in ascending order.