Given a table of medical claims, write a query to calculate the rolling 30-day average of claim amounts per provider.
Use the current claim date and the previous 29 calendar days. Exclude NULL claim amounts from the average, while retaining claims whose amount is NULL in the output.
claim_id, provider_id, claim_date, claim_amount, and rolling_30_day_avgprovider_id ascending with NULL providers last, then claim_date ascending and claim_id ascending| Column | Type | Description |
|---|---|---|
| claim_idPK | INTEGER | Unique identifier for the medical claim |
| provider_id | INTEGER | Identifier of the healthcare provider |
| claim_date | DATE | Date on which the claim was submitted |
| claim_amount | NUMERIC(12,2) | Billed amount for the claim |