title: How to use over partition
body: <p>I have this table:</p>
  <pre><code>ID  BS  time
  1   1   14:10:00
  1   1   14:10:05
  1   1   15:04:03
  1   2   16:18:05
  1   2   17:00:09
  1   3   18:33:50
  1   1   19:03:14
  1   1   19:10:23
  </code></pre>
  <p>and except:</p>
  <pre><code>ID  BS  start_time  end_time
  1   1   14:10:00    16:18:05
  1   2   16:18:05    18:33:50
  1   3   18:33:50    19:03:14
  1   1   19:03:14    19:10:23
  </code></pre>
  <p>I try use lead, but i don't know, how to resolve problem, when BS is repeat after is end</p>
  <pre><code>SELECT id,bs,time,--min(time) time_start,
  lead(time,1) over (partition by id order by time) next_time,
  FROM `sage-facet-114619.Temp_data.temp_table`
  order by id,time
  </code></pre>
  <p>After that I think about group by after this, but I have problem with same BS's</p>