CommencerCommencer gratuitement

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 CASTing the timestamp to a date, let's use one of the functions we just learned to make this faster.

Cet exercice fait partie du cours

Introduction to Redshift

Afficher le cours

Instructions

  • 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.

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

-- 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 ___;
Modifier et exécuter le code