I have a table issue
with following structure:
+----+---------+-------------+------------+
| id | project | new_status | updated_at |
+----+---------+-------------+------------+
| 1 | 1 | New | 12:41:18 |
| 1 | 1 | In progress | 12:47:43 |
| 1 | 1 | Resolved | 17:05:29 |
+----+---------+-------------+------------+
I need to implement a query that returns time that every issue of particular project spent in every status, something like that:
+----+---------+-------------+------------+
| id | project | new_status | time_diff |
+----+---------+-------------+------------+
| 1 | 1 | New | 00:06:25 |
| 1 | 1 | In progress | 04:17:46 |
+----+---------+-------------+------------+
How can I get this? Preferably no special-concrete-db-features should be used, i.e. only pure SQL. But if it matters - I'm using PostgreSQL.