Most Recent Cart per Customer
Problem
**[Asked at Walmart]**
For each customer, find the details of their **most recent shopping order**:
the order date and how many distinct products they purchased that day.
Return `customer_id`, `last_order_date`, and `product_count`,
ordered by customer ID.
Tables
Example rows — the live problem includes the full dataset.
customer_orders
| order_id | customer_id | product_name | amount | order_date |
|---|
Expected output
Your answer should return 4 rows with the columns customer_id, last_order_date, product_count.
Starter code (SQL)
SELECT *
FROM customer_orders;Solve this SQL question free
Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock