gtfs/sql/join-gncy-rts-trps-srvcs-pd...

9 lines
793 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_join_gncy_rts_trps_srvcs_pdts CASCADE;
CREATE OR REPLACE VIEW :schema.vw_join_gncy_rts_trps_srvcs_pdts AS SELECT srvcs.agency_name, srvcs.agency_id, srvcs.route_id, srvcs.route_short_name, srvcs.service_id, srvcs.trip_id, srvcs.trip_short_name, srvcs.trip_headsign, srvcs.dates, pdts.timestamp_pgsql FROM :schema.vw_join_gncy_rts_trps_srvcs AS srvcs LEFT JOIN :schema.trip_updates AS pdts ON srvcs.route_id = pdts.trip_route_id AND srvcs.trip_id = pdts.trip_trip_id ORDER BY srvcs.agency_name, srvcs.route_id, srvcs.trip_id, pdts.timestamp_pgsql;