Describe your approach to joining datasets with mismatched primary keys or differing aggregation levels.
Use the provided tables to reconcile daily campaign metrics with monthly campaign targets. Include only metric records whose external key maps to a campaign, while retaining target-only campaign months.
campaign_id, month_start, total_spend, total_conversions, target_conversions, and conversion_variancecampaign_id, then month_start| Column | Type | Description |
|---|---|---|
| campaign_idPK | INT | Internal campaign identifier |
| external_campaign_key | VARCHAR(30) | Campaign key used by the metrics source |
| campaign_name | VARCHAR(100) | Campaign display name |
| Column | Type | Description |
|---|---|---|
| metric_idPK | INT | Daily metric record identifier |
| external_campaign_key | VARCHAR(30) | External campaign key from the source system |
| metric_date | DATE | Date of the metric record |
| spend | NUMERIC(12,2) | Daily campaign spend |
| conversions | INT | Daily conversion count |
| Column | Type | Description |
|---|---|---|
| target_idPK | INT | Monthly target record identifier |
| campaign_id | INT | Internal campaign identifier |
| month_start | DATE | First day of the target month |
| target_segment | VARCHAR(30) | Optional target segment |
| target_conversions | INT | Conversion target for the segment and month |