Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. select client, status, min(time) as starttime,
  2. lead(min(time)) over (partition by client order by min(time)) as endtime
  3. from (select t.*,
  4. row_number() over (partition by client order by time) as seqnum,
  5. row_number() over (partition by client, status order by time) as seqnum_s
  6. from t
  7. ) t
  8. group by (seqnum - seqnum_s), status, client;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement