Permalink
Browse files

An SQL script to count stops-per-metro in the DB.

  • Loading branch information...
1 parent 908dcdf commit f0e71c2cb0261ba1487277133fbb467262384c89 Matt Conway committed Sep 18, 2012
Showing with 13 additions and 0 deletions.
  1. +13 −0 utils/countStops.sql
View
@@ -0,0 +1,13 @@
+-- Calculate the number of stops in each metro, and sort descending
+SELECT m.id, m.name, sum(g.stops)
+ FROM MetroArea m
+ JOIN MetroArea_NtdAgency mn ON (m.id = mn.metroarea_id)
+ JOIN NtdAgency n ON (mn.agencies_id = n.id)
+ JOIN NtdAgency_GtfsFeed ng ON (ng.ntdagency_id = n.id)
+ JOIN GtfsFeed g ON (ng.feeds_id = g.id)
+ WHERE g.supersededBy_id IS NULL
+ AND g.status = 'SUCCESSFUL'
+ AND NOT g.disabled
+ GROUP BY m.id
+ ORDER BY 3 DESC;
+

0 comments on commit f0e71c2

Please sign in to comment.