Write a SQL query to combine campaign performance data from multiple tables and calculate key marketing metrics by channel.
Use all campaign rows, including channels with no activity. Count approved conversions and handle missing values and zero denominators appropriately.
channel, impressions, clicks, spend, conversions, attributed_revenue, ctr_percent, conversion_rate_percent, cost_per_click, and roas.NULL for undefined rate metrics.channel ascending.| Column | Type | Description |
|---|---|---|
| campaign_idPK | INT | Unique campaign identifier |
| campaign_name | VARCHAR(150) | Campaign name |
| channel | VARCHAR(50) | Marketing channel |
| Column | Type | Description |
|---|---|---|
| campaign_idPK | INT | Campaign receiving the performance activity |
| performance_datePK | DATE | Date of the performance record |
| impressions | INT | Number of ad impressions |
| clicks | INT | Number of ad clicks |
| spend | DECIMAL(12,2) | Campaign spend |
| Column | Type | Description |
|---|---|---|
| conversion_idPK | INT | Unique conversion identifier |
| campaign_id | INT | Campaign attributed to the conversion |
| conversion_status | VARCHAR(20) | Conversion review status |
| attributed_revenue | DECIMAL(12,2) | Revenue attributed to the conversion |