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;Discussion 0
Join free to post in the discussion.
Related questions
- Events and propertiesProduct Manager
- User property or event propertyProduct Manager
- Why write a tracking planProduct Manager
- Users or eventsProduct Manager
- Conversion window in a funnelProduct Manager
- What a cohort isProduct Manager
- Behavioural cohortProduct Manager
- What Day 7 retention measuresProduct Manager