Write a SQL query to analyze operational performance at Notion Labs by team, joining task completion data with team metadata and calculating completion rates by week.
Use the provided task and team tables. Treat a task as completed only when its status is completed, and exclude tasks without a planned date.
team_id, team_name, week_start, total_tasks, completed_tasks, completion_rate_pctteam_id, then week_start ascending| Column | Type | Description |
|---|---|---|
| team_idPK | INT | Unique identifier for the team |
| team_name | VARCHAR(100) | Notion Labs team name |
| department | VARCHAR(100) | Department containing the team |
| manager_email | VARCHAR(255) | Email address of the team manager |
| Column | Type | Description |
|---|---|---|
| task_idPK | INT | Unique identifier for the task |
| team_id | INT | Team responsible for the task |
| planned_at | TIMESTAMP | Timestamp when the task was planned |
| status | VARCHAR(30) | Current task status |