截断日期
您被要求输出按日期降序排列的结果,以及 Coffee County 的每日平均湿度;但该表以每 20 分钟为一个时间间隔记录。虽然可以通过将时间戳 CAST 为日期来实现,但让我们使用刚学到的函数来更高效地完成。
本练习是课程的一部分
Redshift 入门
练习说明
- 在
date时间戳字段上使用一个函数,仅从时间戳中提取日期。 - 按天计算湿度的平均值,字段为
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 ___;