Created
April 30, 2024 16:56
-
-
Save lfy79001/68d4986afbeabd56dc57512b3502903f to your computer and use it in GitHub Desktop.
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
WITH bicycle_rentals AS ( | |
SELECT | |
COUNT(starttime) as num_trips, | |
EXTRACT(DATE from starttime) as trip_date | |
FROM `bigquery-public-data.new_york_citibike.citibike_trips` | |
GROUP BY trip_date | |
), | |
rainy_days AS | |
( | |
SELECT | |
date, | |
(MAX(prcp) > 5) AS rainy | |
FROM ( | |
SELECT | |
wx.date AS date, | |
IF (wx.element = 'PRCP', wx.value/10, NULL) AS prcp | |
FROM | |
`bigquery-public-data.ghcn_d.ghcnd_2016` AS wx | |
WHERE | |
wx.id = 'USW00094728' | |
) | |
GROUP BY | |
date | |
) | |
SELECT | |
ROUND(AVG(bk.num_trips)) AS num_trips, | |
wx.rainy | |
FROM bicycle_rentals AS bk | |
JOIN rainy_days AS wx | |
ON wx.date = bk.trip_date | |
GROUP BY wx.rainy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment