All questions

Advanced · SQL · Window functions

Each customer's latest order

Commonly asked: "Latest record per group" is asked everywhere · ~10 min

Return customer_id, order_id and created_at of each customer's most recent order (ties: highest order id). Sort by customer_id.

Checking your membership…