Your question is Using SQL Window Functions. Start with the requirements and the two tables on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Transport for London wants to monitor short-term changes in passenger entries across its Underground stations. Write a PostgreSQL query that aggregates entries by station and date, then calculates a three-record rolling average for each station.
passenger_entries to stations to return the station name and line.| Column | Type | Description |
|---|---|---|
| station_idPK | INTEGER | Unique TfL station identifier |
| station_name | VARCHAR(100) | Underground station name |
| line | VARCHAR(50) | Primary Underground line serving the station |
| Column | Type | Description |
|---|---|---|
| entry_idPK | INTEGER | Unique passenger entry record identifier |
| station_id | INTEGER | Station associated with the entry record |
| entry_date | DATE | Date on which entries were recorded |
| entry_count | INTEGER | Number of passenger entries, which may be NULL |