How do you optimize slow-running SQL queries or inefficient data extraction processes?
For this hands-on task, write a PostgreSQL query that returns completed customer orders within the specified reporting period and excludes customers below the revenue threshold.
customer_id, customer_name, completed_orders, and total_spend.total_spend of at least 100, ordered by total_spend descending and customer_id ascending for ties.| Column | Type | Description |
|---|---|---|
| customer_idPK | INT | Unique customer identifier |
| customer_name | VARCHAR(100) | Customer display name |
| customer_segment | VARCHAR(30) | Optional customer segment |
| Column | Type | Description |
|---|---|---|
| order_idPK | INT | Unique order identifier |
| customer_id | INT | Customer who placed the order |
| order_date | DATE | Date the order was created |
| status | VARCHAR(20) | Current order status |
| Column | Type | Description |
|---|---|---|
| order_item_idPK | INT | Unique order line identifier |
| order_id | INT | Order containing the item |
| quantity | INT | Number of units purchased |
| unit_price | NUMERIC(10,2) | Price per unit |