You are given a single table of daily StackAdapt campaign performance metrics. Some rows have missing values in impressions, clicks, or spend. Write a SQL query that returns each campaign_name with the number of rows that contain at least one null metric and the average spend after treating null spend values as 0.
This tests whether you can handle incomplete performance data safely in PostgreSQL without dropping rows that still matter for reporting.
campaign_name, rows_with_missing_metrics, and avg_spend_filled.campaign_name in ascending order.avg_spend_filled to two decimal places.| Column | Type | Description |
|---|---|---|
| idPK | INT | Unique row identifier |
| campaign_name | VARCHAR(100) | StackAdapt campaign name |
| metric_date | DATE | Date of the performance record |
| impressions | INT | Number of impressions served |
| clicks | INT | Number of clicks recorded |
| spend | DECIMAL(10,2) | Daily spend in dollars |