Write a SQL query using window functions to identify the top-performing sales representatives by monthly revenue at CarGurus.
Use only completed sales when calculating revenue. Return every representative tied for the highest revenue in a month.
sales_month, rep_id, rep_name, and monthly_revenue.sales_month ascending, monthly_revenue descending, and rep_name ascending.| Column | Type | Description |
|---|---|---|
| rep_idPK | INT | Unique sales representative identifier |
| rep_name | VARCHAR(100) | Sales representative full name |
| team_name | VARCHAR(100) | Sales team assignment |
| Column | Type | Description |
|---|---|---|
| sale_idPK | INT | Unique vehicle sale identifier |
| rep_id | INT | Sales representative associated with the sale |
| sale_date | DATE | Date the sale was recorded |
| revenue | DECIMAL(12,2) | Revenue attributed to the sale |
| sale_status | VARCHAR(20) | Sale status, such as closed or pending |