Write a SQL query using window functions to calculate a running total of daily revenue by user and rank users within each day.
Use the users and revenue_events tables. Include only completed events with non-null amounts. Ties in daily revenue share the same rank.
user_id, user_name, event_date, daily_revenue, running_total, and daily_rank.event_date, daily_rank, and user_id.| Column | Type | Description |
|---|---|---|
| user_idPK | INT | Unique user identifier |
| user_name | VARCHAR(100) | User display name |
| Column | Type | Description |
|---|---|---|
| event_idPK | INT | Unique revenue event identifier |
| user_id | INT | User associated with the event |
| event_date | DATE | Calendar date of the event |
| amount | NUMERIC(12,2) | Revenue amount for the event |
| status | VARCHAR(20) | Processing status of the event |