Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Latest Order per Customer (Correlated)

Return the id of each customer's most recent order, ordered by customer.

Table schema

Orders(id INT PRIMARY KEY, customer VARCHAR(10), order_date DATE)

Sample data

id | customer | order_date
1 | Ann | 2026-01-05
2 | Ann | 2026-03-01
3 | Bob | 2026-02-10
4 | Cy | 2026-01-20
5 | Cy | 2026-01-25

Discussion

No discussions yet.

Rewards · v2.1

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.