Last Updated: May 3, 2026
In a regular join, each table in the FROM clause is independent. A subquery on the right side of a join cannot reference columns from the left side. LATERAL removes that restriction: it lets a subquery run once per row of the preceding table, using that row's values as input.
This makes it the right tool for "top-N per group" queries and other problems where you need a correlated subquery to act like a joined table.