Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.22 KB | None | 0 0
  1. SELECT *,
  2. lag(timestamp) over(partition by user_id order by timestamp) as timestamp_lag,
  3. if(TIMESTAMP_DIFF(timestamp, lag(timestamp) over(partition by user_id order by timestamp),minute)<30,0,1) as session_start
  4. FROM `table_name`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement