How would you use Python string manipulation and basic data structures, along with SQL, to build KPIs from a sample dataset?
Use the provided sample dataset to produce a KPI summary by customer plan. Treat status values case-insensitively after trimming whitespace, and count revenue only for completed orders.
plan, customer_count, total_orders, completed_orders, completion_rate_pct, completed_revenue, and avg_completed_order_value.completed_revenue descending, then plan ascending.| Column | Type | Description |
|---|---|---|
| customer_idPK | INT | Unique customer identifier |
| customer_name | VARCHAR(100) | Customer display name |
| plan | VARCHAR(30) | Customer plan |
| signup_date | DATE | Date the customer signed up |
| Column | Type | Description |
|---|---|---|
| order_idPK | INT | Unique order identifier |
| customer_id | INT | Customer associated with the order |
| order_date | DATE | Date the order was created |
| status | VARCHAR(30) | Order status, potentially inconsistently formatted |
| amount | NUMERIC(10,2) | Order amount |