Postgresql – how do i subtract row pairs in the same table in sql?
I have a table called activity that contains values like the following: userId | timestamp | action ---------------------------------------- 1 | 2022-10-18 10:00:00 | OPEN 2 | 2022-10-18 10:20:00 | OPEN 1 | 2022-10-18 10:05:00 | CLOSE 2 | 2022-10-18 10:22:00…