-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5339e85
commit d4f06e5
Showing
1 changed file
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
-- Obtain the mean ride length, number of rides per membership type per day of the week | ||
SELECT | ||
EXTRACT( | ||
DAYOFWEEK | ||
FROM | ||
started_at | ||
) AS days_of_week, | ||
member_casual, | ||
COUNT(ride_id) AS total_rides, | ||
AVG(CASE WHEN member_casual = 'casual' THEN TIMESTAMP_DIFF(ended_at, started_at, minute) END) AS avg_ride_length_casual_min, | ||
AVG(CASE WHEN member_casual = 'member' THEN TIMESTAMP_DIFF(ended_at, started_at, minute) END) AS avg_ride_length_member_min | ||
FROM | ||
trip_data.year_23 | ||
WHERE | ||
member_casual IN ('casual', 'member') | ||
GROUP BY | ||
member_casual, days_of_week | ||
ORDER BY | ||
days_of_week; |