Context
RealSelf wants a recurring provider performance report covering qualified leads generated through its marketplace and the appointments associated with those leads.
Task
Write PostgreSQL queries to answer the following three questions for January through March 2025. Combine the outputs into one result set with a report_section column so each analysis can be identified.
Requirements
- Report monthly leads, completed appointments, and conversion rate by provider.
- Identify the top two providers by completed appointments each month, including each provider's three-month rolling lead count and monthly rank. Break ties alphabetically by provider name.
- Identify providers whose conversion rate decreased from the previous month, including the previous rate, current rate, and percentage-point change.
- Exclude spam leads, preserve months with zero activity for providers who had at least one valid lead, and treat cancelled or missing appointments as non-conversions.