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

Recency per Customer

As of 2026-06-30, return each customer and the number of days since their most recent order. Order by customer.

Table schema

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

Sample data

id | customer | order_date | amount
1 | Ann | 2026-06-20 | 200
2 | Ann | 2026-06-01 | 150
3 | Bob | 2026-05-01 | 90
4 | Cy | 2026-06-28 | 120
5 | Cy | 2026-06-10 | 60
6 | Cy | 2026-04-01 | 40

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.