Due: Sept 15, 2020 by 11:59pm ET
- Indego Bikeshare data station status data
- Indego Trip data
- Q2 2020
- Q2 2019
All data is available from Indego's Data site. Feel free to use the Station Data from last week if it is not already in your account.
Load all three datasets into your CARTO account.
SELECT count(*)
FROM andyepenn.indego_trips_2019_q2
Result: 206354
Using only the table from Q2 2020 and the number calculated in the previous question, find the percent change of number of trips in Q2 2020 as compared to 2019. Remember you can do calculations in the select clause.
-- Enter your SQL query here
Result:
Bonus: If you want to get fancier here, you can cast the result to a string and concatenate a '%'
to the end. For example, (10 + 3.2)::text || '%' AS perc_change
. This uses the type casting (number to string) and string concatenation operator (||
, double pipes) that's essentially a +
for strings.
Average duration of a trip for 2019.
-- Enter your SQL query here
Result:
Average duration of a trip for 2020.
-- Enter your SQL query here
Result:
What do you notice about the difference in trip lengths? Give a few explanations for why there could be a difference here.
Answer:
-- Enter your SQL query here
Result:
Why are there so many trips of this duration?
Answer:
-- Enter your SQL query here
Result:
Hint 1: date strings can be parsed using the text type to datetime type conversion function to_timestamp
. See the section on Template Patterns for Date/Time Formatting for options on choosing the right string format. The 2020 dataset has the timestamp in a slightly unusual format so you need to tell PostgreSQL how to parse it. The 2019 data should already be in a good format.
Hint 2: Days of the month can be retrieved from a timestamp using the EXTRACT function. See also some of the follow alongs from the Lecture in week 2.
-- Enter your SQL query here
Result:
Using the Q2 2019 trip data, give the five most popular stations.
Hint: Use the EXTRACT
function to get the hour of the day from the timestamp.
-- Enter your SQL query here
Result:
In one query, give a list of all passholder_type
options and the number of trips taken by passholder_type
.
-- Enter your SQL query here
Result:
9. Using the station status dataset, find the distance in meters of all stations from Meyerson Hall.
-- Enter your SQL query here
Don't worry about listing the full result, just give the query.
-- Enter your SQL query here
Result:
-- Enter your SQL query here
Result:
-- Enter your SQL query here
Result:
Write a query that returns only one line, and only gives the station id, station name, and distance from Meyerson Hall.
-- Enter your SQL query here
Result:
Write a query that returns only one line, and only gives the station id, station name, and distance from Meyerson Hall.
-- Enter your SQL query here
Result: