this task is a gap and island problem. The queries I provided couldn't give me correct session_id, but first_ts is correct. I need help to make the query work in correct way.

1 answer below »
this task is a gap and island problem. The queries I provided couldn't give me correct session_id, but first_ts is correct. I need help to make the query work in correct way.
Answered Same DayMar 10, 2023

Answer To: this task is a gap and island problem. The queries I provided couldn't give me correct session_id,...

Vikas answered on Mar 11 2023
44 Votes
Here is the modified version:
-- create temp table with lagged columns
create temp table lags as

select *,
lag(webid, 1, webid) over(partition by userid order by ts) as lag_webid,
lag(ts, 1, ts) over(partition by userid order by ts) as lag_ts
from mytable;
-- identify session...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here