Your question is Average Order Value Per Customer. Start with the requirements and the one table on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
The Zappos Family wants to compare average purchase sizes across customers using order transaction data. Write a PostgreSQL query that calculates the average order value for each customer.
customer_id.order_total, rounded to two decimal places.NULL last.PostgreSQL's AVG ignores NULL order totals. If a customer has no non-NULL order totals, their average should remain NULL.
| Column | Type | Description |
|---|---|---|
| order_idPK | INTEGER | Unique order identifier |
| customer_id | INTEGER | Identifier of the customer who placed the order |
| order_total | NUMERIC(10,2) | Total monetary value of the order |
| order_date | DATE | Date the order was placed |