Daily ER Visits
You are a software engineer working in logistics for a hypothetical hospital in Iceland.
You are responsible for software that determines which supplies to ship where.
Your task is to help ensure that the emergency room (ER) remains adequately stocked with vital supplies.
This depends on the number of patients incoming each day.
The data for daily number of visits each day is in the daily_er_visits
table.
column_name | type |
---|---|
date_t | DATE |
visit_count | INTEGER |
To help the logistics team make forecasts, your software needs to display a moving average, a.k.a. "rolling mean", of the number of people that visit the ER each day. When you have a value that changes over time, a moving average is an average of the current value and n past values. In our case, our moving average should be for a week. So the moving average on 2022-01-09 should be an average of the number of patient visits from 2022-01-03 to 2022-01-09.
For each date in the daily_er_visits
table, select the date, the number of new visitors that day,
and the moving average for the week (name this column avg_visit_count
).
If you were to graph it, it would look something like this.