I have a table
| id | user_id | created_at | status |
|---|---|---|---|
| 1 | 100 | 2022-12-13 00:12:12 | IN_TRANSIT |
| 2 | 104 | 2022-12-13 01:12:12 | IN_TRANSIT |
| 3 | 100 | 2022-12-13 02:12:12 | DONE |
| 4 | 100 | 2022-12-13 03:12:12 | IN_TRANSIT |
| 5 | 104 | 2022-12-13 04:12:12 | DONE |
| 6 | 100 | 2022-12-13 05:12:12 | DONE |
| 7 | 104 | 2022-12-13 06:12:12 | IN_TRANSIT |
| 7 | 104 | 2022-12-13 07:12:12 | REJECTED |
I am trying to calculate the sum for each user of the idle time, so the time between status DONE and next IN_TRANSIT for that user.
The result should be
| user_id | idle_time |
|---|---|
| 100 | 01:00:00 |
| 104 | 02:00:00 |