Explain the difference between a LATERAL JOIN and a correlated subquery. When would you use one over the other?
Role: Data Scientist
Category: Data Manipulation (SQL/Python)
Difficulty: medium
Interview Round: Other
Overview: Compare a LATERAL join with a correlated subquery in SQL: what each can return per outer row, where it can appear in a query, and which one fits a given task such as top-N per group. Tests advanced SQL reasoning about query shape, missing matches and per-row performance.