How to filter last rows based on some criteria from other columns in PostgreSQL
Suppose I have a table (DeliveryEvent) like this grouped by delivery_id, where event_type 2 is an event of 'scheduled', 3 is an event of 'unscheduled', and 4 is an event of 'completed': id created event_type delivery_id extra 1 2022-10-27 18:04…