Write a SQL query to find the top three prescribers for a specific medication in each state, partitioned by year.
Use the provided prescription, prescriber, and medication data. For this exercise, measure prescriber activity by prescription count for Ozempic. Exclude records without a known state and return no more than three prescribers per state and year.
Output
- One row per qualifying prescriber, state, and year
- Columns:
year, state, prescriber_id, prescriber_name, prescription_count, and prescriber_rank
- Sort by
year, state, prescriber_rank, and prescriber_id