Write a SQL query to calculate daily operational KPIs by team, including volume, average handle time, and SLA attainment, from a table of work items and a table of team assignments. Use created_at as the operational date. Average handle time applies to completed items with timestamps, and SLA attainment is the percentage of completed items finished by sla_due_at.
Output
- One row per operational date and team, with
kpi_date, team_name, volume, avg_handle_time_minutes, and sla_attainment_pct.
- Exclude work items without a team assignment and assignments without a matching work item.
- Order by
kpi_date, then team_name.