Write a SQL query to analyze operational performance by joining service delivery, staffing, and client tables, then calculate weekly SLA attainment and average turnaround time by team.
Use completed deliveries associated with active staff and active clients. SLA attainment means completion on or before the SLA deadline. Turnaround time is measured in hours from receipt to completion.
Output
- One row per team and Monday-based week.
- Return
team, week_start, completed_deliveries, sla_attainment_pct, avg_turnaround_hours, and prior_week_sla_pct.
- Include only qualifying completed deliveries, order by
team, then week_start.