Write a query using SQL window functions to calculate the running total revenue per merchant and identify their top 3 highest-grossing days.
Use completed transactions only. Treat NULL revenue as zero when calculating daily revenue, and aggregate multiple transactions for the same merchant and date.
merchant_name, sale_date, daily_revenue, running_total, and top_day_rank.| Column | Type | Description |
|---|---|---|
| merchant_idPK | INT | Unique merchant identifier |
| merchant_name | VARCHAR(100) | Merchant display name |
| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Unique transaction identifier |
| merchant_id | INT | Merchant receiving the transaction |
| sale_date | DATE | Calendar date of the transaction |
| revenue | DECIMAL(12,2) | Revenue generated by the transaction |
| status | VARCHAR(20) | Transaction processing status |