By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
| date | data | data_max |
|---|---|---|
| 2017-01-02 | 2 | 2 |
| 2017-01-03 | 4 | 4 |
| 2017-01-04 | 1 | 4 |
| 2017-01-05 | 3 | 4 |
| 2017-01-06 | 1 | 4 |
| 2017-01-07 | 4 | 4 |
| 2017-01-08 | 5 | 5 |
| 2017-01-09 | -2 | 5 |
| 2017-01-10 | 0 | 5 |
| 2017-01-11 | -5 | 5 |
| 2017-01-12 | 6 | 6 |
| 2017-01-13 | 4 | 6 |
| 2017-01-14 | 6 | 6 |
| data_max | diff_date_from | diff_date_to |
|---|---|---|
| 4 | 2017-01-04 | 2017-01-06 |
| 5 | 2017-01-09 | 2017-01-11 |
| 6 | 2017-01-13 | 2017-01-13 |