截斷日期
你被要求產生一個輸出,內容包含日期(遞減排序)以及 Coffee County 的每日平均濕度;不過,資料表是以每 20 分鐘為一個區間建立的。雖然你可以把時間戳記 CAST 成日期,但我們來使用剛學到的其中一個函式,讓這件事做得更快。
本練習屬於課程
Redshift 入門
練習說明
- 對
date這個 timestamp 欄位使用函式,從時間戳記中只取出日期。 - 依天計算
hourlyrelativehumidity的平均濕度,並以時間倒序排列。 - 以日期分組,並依日期遞減排序。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
-- Select just the actual date from the date field
SELECT ___(___) as day,
-- Calculate the average daily humidity from hourlyrelativehumidity
___(___)
FROM public_intro_redshift.coffee_county_weather
-- Group by the day
GROUP BY ___
-- Order by the day in reverse chronological order.
ORDER BY day ___;