Your question is SQL for Top Customers. 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.
Coalition Greenwich wants to identify its highest-revenue institutional customers for the most recently completed reporting quarter. Assume the reporting date is April 15, 2025, so the last completed calendar quarter is January 1 through March 31, 2025.
Write a PostgreSQL query that returns the top 10 customers by completed-order revenue during Q1 2025.
customers to orders using customer_id.status = 'completed' and an order_date from 2025-01-01 inclusive through 2025-04-01 exclusive.customer_id as a deterministic tie-breaker.| Column | Type | Description |
|---|---|---|
| customer_idPK | INTEGER | Unique customer identifier |
| customer_name | VARCHAR(120) | Institutional customer name |
| region | VARCHAR(40) | Customer operating region |
| Column | Type | Description |
|---|---|---|
| order_idPK | INTEGER | Unique order identifier |
| customer_id | INTEGER | Customer associated with the order |
| order_date | DATE | Date the order was placed |
| status | VARCHAR(20) | Order lifecycle status |
| revenue | NUMERIC(12,2) | Revenue attributed to the order |