We Miss You
Customers who haven't bought anything for a long time get an email with a discount code: “We miss you!” It goes to the customers whose last paid order was placed more than 6 months before the latest order in the shop. (A real shop would count back from today, but the data of Pixel Shop ends in December 2025, so here, the latest order stands in for today.) Show the customer's name and the date of their last paid order as last_order, from the one longest ago:
| name | last_order |
|---|---|
| Leo Walker | 2024-08-23 |
| Ava Green | 2025-04-15 |
| Mia Lewis | 2025-05-20 |
| Liam Turner | 2025-06-06 |
The latest order is from December 22, 2025, so the email goes to the customers whose last paid order is from before June 22, 2025. Leo Walker's last order, from March 2025, was refunded, so his last paid order is the one from August 2024. Customers who have never ordered anything don't get this email: there's another one for them.
A tip: don't type the limit in, as it moves with each new order. Remember how a subquery found the last 30 days of the shop in the lesson on subqueries.
Instructions
Below the comment -- 2. We miss you, write the query for the emails.
Start programming for free
2/3