Write a SQL query to analyze monthly sales operations performance by region, joining orders, reps, and accounts tables to calculate revenue, conversion rate, and month-over-month change.
Use valid orders associated with both a rep and an account. Treat orders with status won as converted and include all valid order statuses in the conversion-rate denominator.
Output
- One row per region and calendar month, with columns
region, month, revenue, conversion_rate, and mom_revenue_change_pct.
- Include only months containing at least one valid order. Sort by
region, then month ascending.
Output details
- Represent
month as the first calendar day of each month.
- Compute
revenue as the sum of amount for won orders, treating NULL amounts as 0.
- Express
conversion_rate as the converted-order percentage and round it to 2 decimal places.
- Express
mom_revenue_change_pct as the percentage change from the preceding output month, round it to 2 decimal places, and return NULL when no preceding revenue exists or it is zero.