Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- WITH users_cnt AS
- SELECT session_start::date AS session_date,
- COUNT(DISTINCT user_id) AS users_cnt
- FROM online_store.sessions
- GROUP BY session_date
- )
- SELECT *,
- LAG(users_cnt, 7) OVER (ORDER BY session_date) AS previous_weekday_users_cnt
- FROM users_cnt;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement