Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select client, status, min(time) as starttime,
- lead(min(time)) over (partition by client order by min(time)) as endtime
- from (select t.*,
- row_number() over (partition by client order by time) as seqnum,
- row_number() over (partition by client, status order by time) as seqnum_s
- from t
- ) t
- group by (seqnum - seqnum_s), status, client;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement