Your question is Top 10 Customers by Spend. 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.
EarthCam wants to identify the customers generating the most revenue from camera, monitoring, and streaming orders. Write a PostgreSQL query that returns the 10 customers with the highest total spend.
customer_name and calculate total spend with SUM(amount).customer_name ascending as a deterministic tie-breaker.A NULL order amount should not contribute to a customer's total. The query should still include that customer if the customer has other valid orders.
| Column | Type | Description |
|---|---|---|
| order_idPK | INT | Unique order identifier |
| customer_name | VARCHAR(150) | Name of the customer |
| amount | NUMERIC(12,2) | Order amount in US dollars |
| order_date | DATE | Date the order was placed |