Blend360 analysts monitor campaign performance across marketing channels. Write a PostgreSQL query that summarizes conversions by channel and day, then compares each result with the previous recorded day for that channel.
Requirements
- Join campaign metadata to daily campaign metrics and include only active campaigns during January 2025.
- Aggregate conversions by
channel and metric_date, treating rows where all conversion values are NULL as zero.
- Use
LAG to return the previous recorded day's conversions for each channel.
- Calculate both the absolute conversion change and percentage change. Return NULL for the first available day or when the previous value is zero.
- Sort the results by channel and metric date.
Output details
- Return columns in this order:
channel, metric_date, daily_conversions, previous_day_conversions, conversion_change, conversion_change_pct.
- Sort by
channel ascending, then metric_date ascending.
- Round
conversion_change_pct to two decimal places.