Created
January 2, 2018 14:42
-
-
Save dutchiechris/e6e136efaebefeeccb6444b8ed729cf6 to your computer and use it in GitHub Desktop.
Simple example of BigQuery (bq) sql join on airline public data set
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 | |
w.airline_name, | |
COUNT(departure_delay) AS delay | |
FROM | |
`bigquery-samples.airline_ontime_data.flights` AS f | |
JOIN ( | |
SELECT | |
REGEXP_EXTRACT( airline ,r'.*: (.*)') as airline_code, | |
REGEXP_EXTRACT( airline ,r'(.*):.*') as airline_name | |
FROM | |
`bigquery-samples.airline_ontime_data.airline_id_codes`) AS w | |
ON | |
w.airline_code = f.airline | |
WHERE | |
departure_delay > 0 | |
AND departure_airport = 'LGA' | |
AND date = '2008-05-13' | |
GROUP BY | |
w.airline_name | |
order by delay desc | |
LIMIT | |
100 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment