Your question is Top 5 Customers in 90 Days. Start with the requirements and the two tables 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.
Intelliswift wants a recent-spend leaderboard for customers using its customer analytics data. Write a PostgreSQL query to identify the five customers with the highest completed-order spend during the last 90 days.
CURRENT_DATE.status = 'completed'.customer_id for tied totals.| Column | Type | Description |
|---|---|---|
| customer_idPK | INT | Unique customer identifier |
| customer_name | VARCHAR(100) | Customer's full name |
| VARCHAR(150) | Customer email address |
| Column | Type | Description |
|---|---|---|
| order_idPK | INT | Unique order identifier |
| customer_id | INT | Customer associated with the order |
| order_date | DATE | Date the order was placed |
| total_amount | NUMERIC(12,2) | Total monetary value of the order |
| status | VARCHAR(20) | Order processing status |