Write a SQL query to calculate weekly campaign conversions, spend, and conversion rate by channel for Direct Agents.
Use the campaigns and campaign_metrics tables. Conversion rate is conversions divided by clicks, expressed as a percentage. Ignore metric records that do not match a campaign.
week_start, channel, conversions, spend, and conversion_rate.week_start ascending and channel ascending.| Column | Type | Description |
|---|---|---|
| campaign_idPK | INTEGER | Unique campaign identifier |
| campaign_name | VARCHAR(100) | Direct Agents campaign name |
| channel | VARCHAR(50) | Marketing channel |
| Column | Type | Description |
|---|---|---|
| metric_idPK | INTEGER | Unique campaign metric record |
| campaign_id | INTEGER | Campaign associated with the metric record |
| metric_date | DATE | Date on which performance was recorded |
| clicks | INTEGER | Number of attributed clicks |
| conversions | INTEGER | Number of attributed conversions |
| spend | NUMERIC(12,2) | Campaign spend for the metric date |