How would you use SQL window functions to find the top 3 products by revenue in each month?
Assume revenue is calculated as quantity multiplied by unit price. Return the three highest-revenue products for every month, using product ID as the deterministic tie-breaker.
month, product_id, product_name, revenue, and revenue_rank.| Column | Type | Description |
|---|---|---|
| product_idPK | INT | Unique product identifier |
| product_name | VARCHAR(100) | Product display name |
| Column | Type | Description |
|---|---|---|
| sale_idPK | INT | Unique sale identifier |
| product_id | INT | Product sold in the transaction |
| sold_at | DATE | Sale date |
| quantity | INT | Number of units sold |
| unit_price | DECIMAL(10,2) | Price per unit |