> (And I don't think the one inside the lateral join is doing you any good). > Try: > ... > a.next_contact is not null > limit 1) sq > order by sq.next_contact DESC;
This re-orders the returned set, but still not in chronological order.
Really? Is your next_contact field a date field and not a text field? What order does it come out in?
(And I assume you saw David J's correction to the misinformation I offered.)