Write a SQL query to analyze support workload by day and team, joining ticket, agent, and schedule tables to identify staffing gaps.
Use the provided tables to compare ticket volume with scheduled agents. Include dates and teams that appear only in schedules or only in ticket activity.
Output
- One row per day and team, with
work_date, team, ticket_count, scheduled_agent_count, workload_per_scheduled_agent, and staffing_gap
staffing_gap is the number of tickets exceeding scheduled agents, with zero when no excess exists
- Include unmatched dates or teams, and order by
work_date ascending, then team ascending