I have a table similar to:
| Date | Person | Distance |
|---|---|---|
| 2022/01/01 | John | 15 |
| 2022/01/02 | John | 0 |
| 2022/01/03 | John | 0 |
| 2022/01/04 | John | 0 |
| 2022/01/05 | John | 19 |
| 2022/01/01 | Pete | 25 |
| 2022/01/02 | Pete | 12 |
| 2022/01/03 | Pete | 0 |
| 2022/01/04 | Pete | 0 |
| 2022/01/05 | Pete | 1 |
I want to find all persons who have a distance of 0 for 3 or more consecutive days. So in the above, it must return John and the count of the days with a zero distance. I.e.
| Person | Consecutive Days with Zero |
|---|---|
| John | 3 |
I'm looking at something like this, but I think this might be way off:
Select Person, count(*),
(row_number() over (partition by Person, Date order by Person, Date))
from mytable