Truncating dates
You've been asked to create an output of a date in descending order and the average daily humidity in Coffee County; however, the table is setup in 20 minute increments. While you could do this by CAST
ing the timestamp to a date, let's use one of the functions we just learned to make this faster.
Diese Übung ist Teil des Kurses
Introduction to Redshift
Anleitung zur Übung
- Use a function on the
date
timestamp field to get just the date from the timestamp. - Calculate the average of the humidity by day,
hourlyrelativehumidity
, and order in reverse chronological order. - Group by the date, and order by the date descending.
Interaktive Übung
Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.
-- 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 ___;