A lending company's risk team wants to monitor daily loan defaults and smooth short-term fluctuations. Write a PostgreSQL query that calculates the 30-day rolling average of daily default events for the reporting period from February 1 through February 10, 2025.
Requirements
- Join
loan_defaults to loans so only defaults belonging to known loans are counted.
- Include every calendar date in the reporting period, including dates with zero defaults.
- Calculate the daily default count and the rolling average across the current date and previous 29 calendar days.
- Round the rolling average to two decimal places and order the result chronologically.