Write a query using SQL window functions to calculate running totals and moving averages of user API requests over a trailing thirty-day window.
Use oracle_users and api_requests. Return one row for each user and calendar date on which that user made requests. The moving average should average daily request counts from the current date and the preceding 29 calendar days. Exclude requests that cannot be matched to a user.
user_id, user_name, request_date, daily_requests, running_total, and moving_avg_30duser_id and request_datemoving_avg_30d to two decimal places| Column | Type | Description |
|---|---|---|
| user_idPK | INT | Unique user identifier |
| user_name | VARCHAR(100) | Display name of the user |
| Column | Type | Description |
|---|---|---|
| request_idPK | INT | Unique API request identifier |
| user_id | INT | User who made the request |
| request_date | DATE | Calendar date of the API request |
| endpoint | VARCHAR(120) | Requested API endpoint |