ARPU/ARPPU: May–Jul 2025, 'Электроника', excl. cancelled
Instructions
Consider only non-cancelled orders (status <> 'cancelled') created from May 1, 2025 to July 31, 2025 inclusive; revenue is the sum of quantity × price of items of the category 'Электроника' (categories.name) in these orders (the price is order_items.price). A city's customers are all customers (customers) with registered_at strictly earlier than August 1, 2025; customers without a city belong to the group 'не указан'. A paying customer is a customer with non-zero such revenue. For each city, output city, customers (the number of customers in the city), payers (the number of paying customers), revenue (their total revenue, 0 if there is none), arpu (revenue / customers) and arppu (revenue / payers; NULL if there are no payers); round arpu and arppu to 2 decimal places. The revenue of customers who registered later is not counted. Sort by city.
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.