1. Learn
  2. /
  3. Courses
  4. /
  5. Functions for Manipulating Data in PostgreSQL

Exercise

Putting it all together

Many of the techniques you've learned in this course will be useful when building queries to extract data for model training. Now let's use some date/time functions to extract and manipulate some DVD rentals data from our fictional DVD rental store.

In this exercise, you are going to extract a list of customers and their rental history over 90 days. You will be using the EXTRACT(), DATE_TRUNC(), and AGE() functions that you learned about during this chapter along with some general SQL skills from the prerequisites to extract a data set that could be used to determine what day of the week customers are most likely to rent a DVD and the likelihood that they will return the DVD late.

Instructions 1/2

undefined XP
    1
    2
  • Extract the day of the week from the rental_date column using the alias dayofweek.
  • Use an INTERVAL in the WHERE clause to select records for the 90 day period starting on 5/1/2005.