Write a SQL query to identify the top-performing marketing channels using window functions.
Use the provided campaign, spend, conversion, and channel data. Evaluate performance monthly using return on ad spend, and include month-over-month ROAS change.
month, channel_name, roas, channel_rank, previous_month_roas, and roas_change.month ascending, channel_rank ascending, and channel_name ascending.| Column | Type | Description |
|---|---|---|
| channel_idPK | INT | Unique marketing channel identifier |
| channel_name | VARCHAR(100) | Marketing channel name |
| Column | Type | Description |
|---|---|---|
| campaign_idPK | INT | Unique campaign identifier |
| channel_id | INT | Associated marketing channel |
| campaign_name | VARCHAR(150) | Campaign name |
| Column | Type | Description |
|---|---|---|
| spend_idPK | INT | Unique spend record identifier |
| campaign_id | INT | Campaign receiving the spend |
| spend_date | DATE | Date of the spend |
| spend_amount | NUMERIC(12,2) | Amount spent |
| Column | Type | Description |
|---|---|---|
| conversion_idPK | INT | Unique conversion identifier |
| campaign_id | INT | Campaign attributed to the conversion |
| conversion_date | DATE | Date of the conversion |
| conversion_value | NUMERIC(12,2) | Revenue attributed to the conversion |