How do you optimize a slow SQL query?
Review the query represented by the supplied tables and produce an efficient PostgreSQL query that returns only qualifying active customers. The result must calculate completed 2025 order revenue and exclude customers whose total is not greater than 1,000.
customer_id, customer_name, total_completed_revenue.| Column | Type | Description |
|---|---|---|
| customer_idPK | INT | Unique customer identifier |
| customer_name | VARCHAR(100) | Customer display name |
| status | VARCHAR(20) | Customer lifecycle status |
| Column | Type | Description |
|---|---|---|
| order_idPK | INT | Unique order identifier |
| customer_id | INT | Customer who placed the order |
| order_date | DATE | Date the order was placed |
| amount | DECIMAL(12,2) | Order value |
| status | VARCHAR(20) | Order processing status |