Write a SQL query to analyze operational performance by joining member, queue, and outcome tables and calculating weekly completion rates.
Use the provided tables to calculate results for every queue and every week represented by valid member outcomes. Treat an outcome with status completed as completed. Include queues with no outcomes in a represented week.
Output
- One row per queue and week, with columns
queue_name, week_start, total_outcomes, completed_outcomes, and completion_rate.
- Include weeks beginning Monday, order by
week_start, then queue_name.
- Return completion rates as percentages rounded to two decimal places, using
0.00 when no outcomes exist.
Output details
- Count only outcomes associated with existing member and queue records.
- Count every matching outcome row without deduplication, preserving separate queue records even when
queue_name values repeat.
- Treat statuses other than exact
completed, including NULL, as not completed while still counting their outcomes in total_outcomes.