Not sure how I would describe this, so I think my title might be a bit off. But it comes down to: "Please write this request for me, I'm stuck like hell"
I have two tables (only for the relevant parts)
I want to return the list in this form
Entity.Id,Name,"latest related log entry username WITH a username not null"
But log entries may contain newer entries without a username. So I need the last entry with the username.
I get a list of entities and request the last entry separately, but this gives me scary N + 1 queries for the report.
source share