Is it possible to get the most recent record for each group?

Hi everyone!

I have a table candidate link to tables order and worker. Each line in this table candidate have different status like:

I want to make a query all request filtered by "where order_id = input.order_id" to fetch only the candidates of a specific order. But I want to only have one record per worker_id so I can get the latest status of each worker that are candidate on a specific order.

Example with where order_id = 2


{ id: 3, status: "status 1", worker_id: 1 },

{ id: 2, status: "status 2", worker_id: 2 }


I can get that by using the query all with a group by and an aggregate like this:

My issue is that I want to get details of the candidate like his status which I will not get with this request cause it's not part of the aggregation.

Have a nice day!