feat: add union of trps, stptms and stps
This commit is contained in:
parent
5b563e7b5e
commit
02ac54ea2b
|
@ -0,0 +1,8 @@
|
|||
-- 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_join_gncy_rts_trps_stptms_stps CASCADE;
|
||||
CREATE OR REPLACE VIEW :schema.vw_join_gncy_rts_trps_stptms_stps AS SELECT gncy_rts_trps_stptms.agency_id, gncy_rts_trps_stptms.agency_name, gncy_rts_trps_stptms.stop_id, stps.stop_name FROM :schema.vw_join_gncy_rts_trps_stptms AS gncy_rts_trps_stptms JOIN :schema.stops AS stps ON gncy_rts_trps_stptms.stop_id = stps.stop_id ORDER BY gncy_rts_trps_stptms.agency_name, stps.stop_name;
|
|
@ -0,0 +1,9 @@
|
|||
-- 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_join_gncy_rts_trps_stptms CASCADE;
|
||||
--CREATE OR REPLACE VIEW :schema.vw_join_gncy_rts_trps_stptms AS SELECT gncy_rts_trps.agency_id, gncy_rts_trps.agency_name, gncy_rts_trps.route_id, gncy_rts_trps.route_short_name, gncy_rts_trps.service_id, gncy_rts_trps.trip_id, gncy_rts_trps.trip_short_name, gncy_rts_trps.trip_headsign, stptms.stop_id FROM :schema.vw_join_gncy_rts_trps AS gncy_rts_trps RIGHT JOIN :schema.stop_times AS stptms ON gncy_rts_trps.trip_id = stptms.trip_id ORDER BY gncy_rts_trps.agency_name, gncy_rts_trps.route_id, gncy_rts_trps.trip_id;
|
||||
CREATE OR REPLACE VIEW :schema.vw_join_gncy_rts_trps_stptms AS SELECT gncy_rts_trps.agency_id, gncy_rts_trps.agency_name, stptms.stop_id FROM :schema.vw_join_gncy_rts_trps AS gncy_rts_trps RIGHT JOIN :schema.stop_times AS stptms ON gncy_rts_trps.trip_id = stptms.trip_id GROUP BY stptms.stop_id, gncy_rts_trps.agency_id, gncy_rts_trps.agency_name ORDER BY gncy_rts_trps.agency_name;
|
|
@ -0,0 +1,8 @@
|
|||
-- 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_count_gncy CASCADE;
|
||||
CREATE OR REPLACE VIEW :schema.vw_stps_count_gncy AS SELECT stps.agency_id, stps.agency_name, count(DISTINCT stps.stop_id) AS stop_count FROM :schema.vw_join_gncy_rts_trps_stptms_stps AS stps GROUP BY stps.agency_id, stps.agency_name ORDER BY stop_count ASC;
|
|
@ -0,0 +1,8 @@
|
|||
-- 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_stops_lt_0 CASCADE;
|
||||
CREATE OR REPLACE VIEW :schema.vw_stops_lt_0 AS SELECT * FROM :schema.stops WHERE location_type=0;
|
Loading…
Reference in New Issue