Date parts
The date_part()
function is useful when you want to aggregate data by a unit of time across multiple larger units of time. For example, aggregating data by month across different years, or aggregating by hour across different days.
Recall that you use date_part()
as:
SELECT date_part('field', timestamp);
In this exercise, you'll use date_part()
to gain insights about when Evanston 311 requests are submitted and completed.
This exercise is part of the course
Exploratory Data Analysis in SQL
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
-- Extract the month from date_created and count requests
SELECT ___ AS month,
___
FROM evanston311
-- Limit the date range
WHERE ___
AND ___
-- Group by what to get monthly counts?
GROUP BY ___;