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
Select NTILE(4) over (order by rn), | |
avg_total_rides, | |
station_id, | |
num_bikes_available | |
from | |
( | |
select | |
row_number() over (order by avg_total_rides desc) rn, | |
t1.station_id, | |
avg_total_rides, | |
num_bikes_available | |
from | |
( | |
select | |
avg(total_rides) avg_total_rides, | |
station_id | |
from | |
( | |
select | |
sum(total_rides) total_rides, | |
start_date, | |
c."start station id" station_id | |
from | |
( | |
select | |
cast(cast(starttime as datetime) as date) start_date, | |
1 total_rides, | |
b."start station id" | |
from | |
bike_rides b | |
) c | |
group by | |
start_date, | |
c."start station id" | |
) d | |
group by | |
station_id | |
) t1 | |
join ( | |
select | |
distinct station_id, | |
b.num_bikes_available |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment