Production SQL patterns for marketing and revenue analytics. Built for Snowflake with dbt-compatible syntax.
| File | Description |
|---|---|
campaign_performance.sql | ROAS, CPM, CTR, and CPA by campaign |
top_n_per_group.sql | Top N results per partition using ROW_NUMBER |
budget_pacing.sql | Flag campaigns behind pace vs. expected spend |
wow_change.sql | Week-over-week metric change using LAG |
- Warehouse: Snowflake
- Transformation: dbt
- Use case: Marketing analytics, revenue reporting, campaign performance
All queries use NULLIF to prevent division by zero. Window function filtering uses Snowflake's QUALIFY clause where applicable.