Store delivery scorecard
Store delivery scorecard
You are a data analyst at a convenience store chain. The head of operations is preparing a weekly summary of online orders and wants a per-store picture: how many orders were placed in total, how many reached the customer, how many were cancelled, and how much revenue came from delivered orders only. The data lives in the orders table: one row per order, status is one of 'delivered', 'cancelled', 'returned', and the order amount is always present (never NULL).
Conditional metrics are computed with conditional aggregation: a CASE expression inside an aggregate function.
Return columns:
- store — store name (text);
- total_orders — total number of the store's orders (integer);
- delivered_cnt — number of orders with status 'delivered' (integer);
- cancelled_cnt — number of orders with status 'cancelled' (integer);
- delivered_revenue — sum of amount over delivered orders only, rounded to 2 decimals; 0 if the store has no delivered orders.
Sorting: by store ascending. Every store present in the table appears exactly once; the 'returned' status only contributes to total_orders.
Exemplo de resposta esperada
É assim que se parece uma resposta correta: ela tem seu próprio número de linhas e não precisa coincidir com as tabelas do esquema. Sua resposta precisa retornar os mesmos nomes de colunas do exemplo: use AS para renomeá-las se for preciso.
| store | total_orders | delivered_cnt | cancelled_cnt | delivered_revenue |
|---|---|---|---|---|
| downtown | 5 | 3 | 1 | 245.5 |
| harbor | 4 | 2 | 2 | 259.5 |
| uptown | 6 | 3 | 1 | 206 |
Entre para ver seu histórico de envios
EntrarEntre para usar o AI Mentor
Entrar