A bikeshare company has reached a recent milestone, and their marketing team wants to write a blog post that “congratulates” their most-used bike on being so popular. They want to include the name of the station that the bike is most likely to be found.
They task me with figuring out the station from which the bike begins a trip most frequently. In order to do this, I will need to create a temp table to find the ID number of the bike that has taken the longest total trips (in minutes). I will take a sum of the minutes of each trip for each bike, then sort by descending order to find the bike that has spent the most minutes being used.
Now that I have found the ID of the bike that has been used the longest, I will write a query to find the station from which this bike leaves most frequently. To do this, I will join my temp table (containing just the bike’s ID) with the original table and return the station ID with the highest number of trips started.
Now, it's time to write an INNER JOIN, which you will use to pick out the station ID that corresponds to the bike you identified in the temporary table.
So the final query should appear like this:
TAGS :
Comments are closed.
|
ISRIL CANIAGONEED HELP?
Please feel free to reach out to me if you have any questions
Categories
All
|
© 2017 Isril Caniago. All rights reserved