Write a SQL query to join multiple tables and calculate a monthly summary of analyst-relevant metrics.
Use the provided analyst, activity, and target tables. Include activity from January through March 2025 and preserve months that have activity but no matching target.
analyst_name, month_start, activity_count, completed_count, total_metric_value, average_metric_value, target_value, attainment_percentageanalyst_id, then month_start| Column | Type | Description |
|---|---|---|
| analyst_idPK | INT | Unique analyst identifier |
| analyst_name | VARCHAR(100) | Analyst display name |
| region | VARCHAR(50) | Analyst reporting region |
| active_flag | BOOLEAN | Whether the analyst is currently active |
| Column | Type | Description |
|---|---|---|
| activity_idPK | INT | Unique activity identifier |
| analyst_id | INT | References analysts.analyst_id |
| activity_date | DATE | Date when the activity occurred |
| activity_type | VARCHAR(50) | Type of analyst activity |
| status | VARCHAR(30) | Current activity status |
| metric_value | DECIMAL(12,2) | Numeric value associated with the activity |
| Column | Type | Description |
|---|---|---|
| target_idPK | INT | Unique monthly target identifier |
| analyst_id | INT | References analysts.analyst_id |
| target_month | DATE | First day of the target month |
| target_value | DECIMAL(12,2) | Target metric value for the month |