RienSQL
TASK #163 · Hard · Delivery Hero

Loyal Berlin Pizza Customers

Your brief
Assume today is March 31, 2024. Treat "the last 30 days" as the range from March 2, 2024 to March 31, 2024 inclusive.

Write a query that returns customer_name for customers who satisfy all three conditions:
  • are registered in the city Berlin (country Germany);
  • placed strictly more than three orders in the last 30 days;
  • their most recent order (by order_placed) contains at least one line item whose name includes the substring "Pizza".
Sort the result by customer_name ascending.
Expected columnscustomer_nameDelivery Hero
SQL editor
SQLite
Ctrl / ⌘ + ↵
Result

Write a query and run it to see the results.

Schema
citiescity_id, city_name, country
customerscustomer_id, name, city_id
restaurantsrestaurant_id, name, city_id
ordersorder_id, customer_id, restaurant_id, order_placed, order_delivered
order_itemsitem_id, order_id, product_name