I have got following table:
+---------------------+--------+----------+
| MeasureInterval | Car_id | Distance |
+---------------------+--------+----------+
| 2020-12-15 17:00:00 | 1 | 20 |
+---------------------+--------+----------+
| 2020-12-15 17:05:00 | 1 | 30 |
+---------------------+--------+----------+
| 2020-12-15 17:10:00 | 1 | 17 |
+---------------------+--------+----------+
| 2020-12-15 17:15:00 | 1 | 0 |
+---------------------+--------+----------+
| 2020-12-15 17:20:00 | 1 | 0 |
+---------------------+--------+----------+
| 2020-12-15 17:25:00 | 1 | 10 |
+---------------------+--------+----------+
| 2020-12-15 17:30:00 | 1 | 15 |
+---------------------+--------+----------+
| 2020-12-15 17:35:00 | 1 | 0 |
+---------------------+--------+----------+
| 2020-12-15 17:40:00 | 1 | 0 |
+---------------------+--------+----------+
| 2020-12-15 17:45:00 | 1 | 0 |
+---------------------+--------+----------+
I am trying to select the continous intervals where the car was moving (ignoring the intervals where Distance=0), so it this the results would be something like:
+---------------------+---------------------+--------+--------------+
| | | | |
| MeasureInterval_min | MeasureInterval_max | Car_id | Distance_sum |
+---------------------+---------------------+--------+--------------+
| 2020-12-15 17:00:00 | 2020-12-15 17:10:00 | 1 | 67 |
+---------------------+---------------------+--------+--------------+
| 2020-12-15 17:25:00 | 2020-12-15 17:30:00 | 1 | 25 |
+---------------------+---------------------+--------+--------------+
Any idea how to achieve this?