Write a SQL query to join operational performance data with team and client tables, then calculate monthly KPI trends by business unit.
Use kpi_value as the KPI measure. Include only operational records with matching teams and clients, and ignore NULL KPI values in averages.
month, business_unit, avg_kpi, active_client_count, previous_month_kpi, and kpi_change_pct| Column | Type | Description |
|---|---|---|
| performance_idPK | INT | Unique operational performance record |
| team_id | INT | Team responsible for the performance record |
| client_id | INT | Client associated with the performance record |
| performance_date | DATE | Date on which the KPI was measured |
| kpi_value | DECIMAL(10,2) | Measured operational KPI value |
| Column | Type | Description |
|---|---|---|
| team_idPK | INT | Unique team identifier |
| team_name | VARCHAR(100) | Team name |
| business_unit | VARCHAR(100) | Business unit containing the team |
| Column | Type | Description |
|---|---|---|
| client_idPK | INT | Unique client identifier |
| client_name | VARCHAR(150) | Client name |
| client_status | VARCHAR(20) | Current client status |