db.l3.ai

Play

lessons

what-changed-in-19

editor

engine: not started

results

Run a query to see rows here.

check

LATERAL top-N

LATERAL lets a subquery in FROM use columns of the tables to its left, so 'top N per group' becomes a short query with LIMIT.

task

For each of the 5 customers with most orders (ties by lower id), their 3 latest orders.

hints