Created
July 22, 2014 21:15
-
-
Save nckltcha/f8fb4402ce5b27eda044 to your computer and use it in GitHub Desktop.
gmdata closest stops
This file contains hidden or 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 distinct stops.stop_id, stops.stop_name, route_long_name, arrival_time, ( 3959 * ACOS( COS( RADIANS( 53.48 ) ) * COS( RADIANS(stop_lat ) ) * COS( RADIANS( stop_lon ) - RADIANS( - 2.25 ) ) + SIN( RADIANS( 53.48 ) ) * SIN( RADIANS( stop_lat ) ) ) ) AS distance | |
| FROM stops | |
| LEFT JOIN stop_times ON stops.stop_id = stop_times.stop_id | |
| LEFT JOIN trips ON stop_times.trip_id = trips.trip_id | |
| LEFT JOIN routes ON routes.route_id = trips.route_id | |
| WHERE routes.route_type =0 | |
| AND arrival_time | |
| BETWEEN CURRENT_TIME( ) | |
| AND ADDTIME( CURRENT_TIME( ) , '00:10:00.0' ) | |
| having distance <1 | |
| ORDER BY arrival_time | |
| LIMIT 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment