gtfs/sql/stps-cnt.sql

9 lines
512 B
SQL

-- colon before variable: for a prepared statement using named placeholders, this will be a parameter name of the form :name
CREATE SCHEMA IF NOT EXISTS :schema;
SET search_path to :schema, public;
-- create view
DROP VIEW IF EXISTS :schema.vw_stps_cnt CASCADE;
CREATE OR REPLACE VIEW :schema.vw_stps_cnt AS SELECT stps.agency_id, stps.agency_name, count(DISTINCT stps.stop_id) AS stps_cnt FROM :schema.vw_join_gncy_rts_trps_stptms_stps AS stps GROUP BY stps.agency_id, stps.agency_name ORDER BY stps_cnt ASC;