開始使用免費開始

依欄位分割(PARTITION BY)

你拿到多個氣象站的每月氣溫資料,正要分析各站的最低氣溫。

你想依 station_id 分組,將每月的最低氣溫與該氣象站在 2010 年的全年最低氣溫做比較。

本練習屬於課程

PostgreSQL 的時間序列分析

檢視課程

練習說明

  • 使用視窗函式,在篩選為 2010 年的資料中,依 station_id 分組找出 t_monthly_min 的最小值。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

-- Use a window function to find the minimum temperatures
SELECT
	station_id,
    year_month,
    t_monthly_min,
    ___
FROM temperatures_monthly
WHERE ___;
編輯並執行程式碼