1. Learn
  2. /
  3. Courses
  4. /
  5. Exploratory Data Analysis in SQL

Connected

Exercise

Variation by day of week

Does the time required to complete a request vary by the day of the week on which the request was created?

We can get the name of the day of the week by converting a timestamp to character data:

to_char(date_created, 'day') 

But character names for the days of the week sort in alphabetical, not chronological, order. To get the chronological order of days of the week with an integer value for each day, we can use:

EXTRACT(DOW FROM date_created)

DOW stands for "day of week."

Instructions

100 XP
  • Select the name of the day of the week the request was created (date_created) as day.
  • Select the mean time between the request completion (date_completed) and request creation as duration.
  • Group by day (the name of the day of the week) and the integer value for the day of the week (use a function).
  • Order by the integer value of the day of the week using the same function used in GROUP BY.