I have a table in a PostgreSQL database like this:
ID|Item-FK |timestamp|status
=============================
1 | 123 | ... | EXPIRED
2 | 123 | ... | PENDING
...
I want to query all items where the last two statuses are 'EXPIRED' & 'PENDING' like displayed in the sample above - 'PENDING' latest and 'EXPIRED' immediately before that.
timestamporID? Is there also a tableitemswith with 1 row per item of interest (like "FK" seems to suggest)? And how many rows per item on average? – Erwin Brandstetter Dec 24 '18 at 03:42