How would you use SQL window functions to compute rolling fraud rates by user over time?
Assume fraud rate means fraudulent transactions divided by all transactions in the seven-day period ending on each transaction date. Return results only for dates on which a user has transactions.
user_id, transaction_date, fraudulent_transactions, total_transactions, and rolling_fraud_rate.user_id and transaction_date ascending.| Column | Type | Description |
|---|---|---|
| user_idPK | INT | Unique user identifier |
| user_name | VARCHAR(100) | User display name |
| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Unique transaction identifier |
| user_id | INT | User associated with the transaction |
| transaction_date | DATE | Calendar date of the transaction |
| is_fraudulent | BOOLEAN | Whether the transaction was classified as fraudulent |