Skip to content
RED SAGSkills
medium10 pts · first answer countsproduct-analyticssql

Days between orders with LAG

Why is gap_days NULL for some rows in this query?

SELECT user_id, order_date,
  order_date - LAG(order_date) OVER (
    PARTITION BY user_id ORDER BY order_date) AS gap_days
FROM orders;
Choose one answer

Discussion 0

Join free to post in the discussion.

Related questions