# The best NY predictors, by quarter query = """SELECT a.q, a.departure_state, b.departure_state, corr(a.avg, b.avg) corr, COUNT(*) c FROM (SELECT QUARTER(timestamp(date)) q, date, departure_state , AVG(departure_delay) avg , COUNT(*) c FROM [bigquery-samples:airline_ontime_data.flights] WHERE departure_state = 'NY' GROUP BY 1,2,3 HAVING c > 5 ) a JOIN (SELECT QUARTER(timestamp(date)) q, DATE(DATE_ADD(timestamp(date), 1, 'DAY')) date, departure_state , AVG(departure_delay) avg, COUNT(*) c FROM [bigquery-samples:airline_ontime_data.flights] GROUP BY 1,2,3 HAVING c > 5 ) b ON a.date=b.date AND a.q = b.q GROUP EACH BY 1, 2, 3 HAVING c > 5 ORDER BY corr DESC;""" fields , data = client . ReadSchemaAndRows ( client . Query ( query )[ 'configuration' ][ 'query' ][ 'destinationTable' ], max_rows = 1000 ) data [ 0 : 30 ]