Skip to content

Instantly share code, notes, and snippets.

@luqmaan
Created June 23, 2014 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luqmaan/b9982f075da3c43f2e71 to your computer and use it in GitHub Desktop.
Save luqmaan/b9982f075da3c43f2e71 to your computer and use it in GitHub Desktop.
Get the routes nearby whole foods, note the location comparison part is total garbage
SELECT * FROM trips,
(
SELECT * FROM stop_times,
(
SELECT * FROM stops
WHERE stop_lat > 30.260650 AND stop_lat < 30.280650
AND stop_lon < -97.743562 AND stop_lon > -97.763562
) as nearby_stops
WHERE stop_times.stop_id = nearby_stops.stop_id
GROUP BY trip_id
) as nearby_trips
WHERE trips.trip_id = nearby_trips.trip_id
GROUP BY route_id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment