By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
7 rows affected
| customer_id | login | LEAD | day_diff |
|---|---|---|---|
| 1 | 2016-03-01 | 2016-03-02 | 1 |
| 1 | 2016-03-02 | 2016-03-03 | 1 |
| 1 | 2016-03-03 | 2016-03-05 | 0 |
| 1 | 2016-03-05 | 2016-03-06 | 1 |
| 1 | 2016-03-06 | 2016-03-07 | 1 |
| 1 | 2016-03-07 | 2016-03-08 | 1 |
| 1 | 2016-03-08 | 2016-03-08 | 1 |
| customer_id | highest_consecutive_day |
|---|---|
| 1 | 4 |