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

Days Since Last Order

Treat 2026-10-06 as today. For each customer return the number of days since their most recent order. Order by customer_id.

Table schema

Orders(id INT PRIMARY KEY, customer_id INT, order_date DATE)

Sample data

id | customer_id | order_date
1 | 1 | 2026-09-26
2 | 1 | 2026-10-01
3 | 2 | 2026-08-07

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.