Your question is Advanced SQL With CTEs. Start with the requirements and the three tables on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Microsoft Teams administrators need a monthly view of license utilization and employee engagement across departments.
Write a PostgreSQL query using multiple CTEs to produce adoption metrics for January and February 2025. Include departments with active licenses even when they have no Teams activity.
LAG.| Column | Type | Description |
|---|---|---|
| employee_idPK | INT | Unique employee identifier |
| employee_name | VARCHAR(100) | Employee display name |
| department | VARCHAR(50) | Employee department |
| Column | Type | Description |
|---|---|---|
| license_idPK | INT | Unique license record identifier |
| employee_id | INT | Employee assigned the license |
| license_type | VARCHAR(50) | Microsoft Teams license tier |
| license_status | VARCHAR(20) | License lifecycle status |
| Column | Type | Description |
|---|---|---|
| activity_idPK | INT | Unique activity event identifier |
| employee_id | INT | Employee generating the activity |
| activity_date | DATE | Date of the Teams activity |
| activity_type | VARCHAR(40) | Type of Teams activity |