My target is how can I count the difference/gap before the userID appears again on the table?
This is my table (testing.tbl)
| UserID | Name | Datetime |
|---|---|---|
| 1 | sport | 2021-10-15 13:00:01 |
| 2 | it | 2021-10-15 13:01:02 |
| 3 | game | 2021-10-15 13:01:31 |
| 1 | sport | 2021-10-15 13:01:50 |
| 1 | game | 2021-10-15 13:02:01 |
| 3 | it | 2021-10-15 13:03:54 |
| 3 | sport | 2021-10-15 13:04:05 |
| 2 | it | 2021-10-15 13:05:00 |
This is their difference count. These results happen because I counted the difference before they appeared in the table again.
My target result:
| userID | Difference | Difference |
|---|---|---|
| 1 | 2 | 0 |
| 2 | 5 | |
| 3 | 2 | 0 |
