Loading…
A customer team needs the purchase before and after each completed ecommerce order. Use ecommerce_orders and keep only completed orders. Within each customer, order purchases by order_date and order_id so ties are deterministic.
Return exactly four columns: customer_id, order_date, previous_purchase_date, and next_purchase_date. Return one row per completed order, ordered by customer_id, order_date, and order_id.
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.