On Thu, 4 Dec 2025, David G. Johnston wrote:
I would go with a lateral join subquery of the contracts table. Using an aggregates to perform ranking is an anti-pattern. You want the contract ranked first when ordered by contract_date. Either use a window function to explicitly rank the contracts or use a limit/fetch clause to simply return the first ordered one.
David, It's 'contacts' rather than 'contracts'; a minor typo. I'll read on making a lateral join. Thanks.
You also seem to have completely missed joining people to contracts - suggest using explicit “join” clauses to make that error less likely.
Oops! My bad. Fixed. Regards, Rich
