多組跑動平均
團隊主管對你為夏威夷計算跑動平均的成果印象深刻。現在他們決定需要所有測站的每月最低溫跑動平均。幸好你已經知道如何快速完成這件事。
本練習屬於課程
PostgreSQL 的時間序列分析
練習說明
- 使用視窗函式,對不同時間序列計算
t_monthly_min的跑動平均。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
-- Calculate the running average of the lowest temperates for all stations
SELECT
ts.state,
year_month,
t_monthly_min,
___ AS running_avg_temp
FROM temperatures_monthly AS tm
JOIN temperature_stations AS ts
USING(station_id)
ORDER BY ts.state, year_month;