Assuming I have this data in a table:
id | thing | operation | timestamp
----+-------+-----------+-----------
0 | foo | add | 0
0 | bar | add | 1
1 | baz | remove | 2
1 | dim | add | 3
0 | foo | remove | 4
0 | dim | add | 5
Is there any way to construct a Postgres SQL query that will group by id and operation but without grouping rows with a higher timestamp value over those with lower? I want to get this out of the query:
id | things | operation
----+----------+-----------
0 | foo, bar | add
1 | baz | remove
1 | dim | add
0 | foo | remove
0 | dim | add
Basically group by, but only over adjacent rows sorted by timestamp.