Spend growth x1.5: 3+3 mo. from May 1, 2025
Instructions
A customer's spending for a period is the sum of quantity * order_items.price over the items of their orders with a status other than 'cancelled'. Compare two adjacent periods: A is orders created on or after May 1, 2025 and strictly before August 1, 2025; B is on or after August 1, 2025 and strictly before November 1, 2025. Find customers who had spending in both periods and whose spending in period B is strictly greater than their spending in period A multiplied by 1.5 (spend_b > spend_a * 1.5). Output the customer's id and name, spend_a and spend_b. Row order does not matter.
Hints
Each next one is more detailed and costs more
Query
Result
Click Run to see the query result, or Check to submit your solution.
Dataset schema
Table relationships
- N:1Many-to-one
order_items.→order_id orders.id - N:1Many-to-one
order_items.→product_id products.id - N:1Many-to-one
orders.→customer_id customers.id - N:1Many-to-one
products.→category_id categories.id
Table data
Select a table in the diagram or list to view its rows.