This commit is contained in:
dancingCycle 2023-12-22 00:43:19 +01:00
parent 9de5f1d7dd
commit 52fc3d4681
3 changed files with 4 additions and 4 deletions

View File

@ -5,5 +5,4 @@ SET search_path to :schema, public;
---create view
DROP VIEW IF EXISTS :schema.vw_join_gncy_rts_trps_srvcs CASCADE;
CREATE OR REPLACE VIEW :schema.vw_join_gncy_rts_trps_srvcs 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, srvcs.dates FROM :schema.vw_join_gncy_rts_trps AS gncy_rts_trps LEFT JOIN :schema.services AS srvcs ON gncy_rts_trps.service_id = srvcs.service_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_srvcs 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, srvcs.dates FROM :schema.vw_join_gncy_rts_trps AS gncy_rts_trps LEFT JOIN :schema.services AS srvcs ON gncy_rts_trps.service_id = srvcs.service_id ORDER BY gncy_rts_trps.agency_name, gncy_rts_trps.route_id, gncy_rts_trps.trip_id;

View File

@ -4,4 +4,5 @@ CREATE SCHEMA IF NOT EXISTS :schema;
SET search_path to :schema, public;
-- create view
DROP VIEW IF EXISTS :schema.vw_route_count CASCADE;
CREATE OR REPLACE VIEW :schema.vw_route_count AS SELECT gncy_rts.agency_id, gncy_rts.agency_name, count(DISTINCT gncy_rts.route_id) AS route_count FROM :schema.vw_join_gncy_rts AS gncy_rts GROUP BY gncy_rts.agency_id, gncy_rts.agency_name ORDER BY route_count ASC;

View File

@ -4,5 +4,5 @@ CREATE SCHEMA IF NOT EXISTS :schema;
SET search_path to :schema, public;
---create view
CREATE OR REPLACE VIEW :schema.vw_trip_count AS
SELECT gncy_rts_trps.agency_name, gncy_rts_trps.agency_id, count(DISTINCT gncy_rts_trps.route_id) AS route_count, count(DISTINCT gncy_rts_trps.trip_id) AS trip_count FROM :schema.vw_join_gncy_rts_trps AS gncy_rts_trps GROUP BY gncy_rts_trps.agency_id, gncy_rts_trps.agency_name ORDER BY route_count ASC, trip_count ASC;
DROP VIEW IF EXISTS :schema.vw_trip_count CASCADE;
CREATE OR REPLACE VIEW :schema.vw_trip_count AS SELECT gncy_rts_trps.agency_name, gncy_rts_trps.agency_id, count(DISTINCT gncy_rts_trps.route_id) AS route_count, count(DISTINCT gncy_rts_trps.trip_id) AS trip_count FROM :schema.vw_join_gncy_rts_trps AS gncy_rts_trps GROUP BY gncy_rts_trps.agency_id, gncy_rts_trps.agency_name ORDER BY route_count ASC, trip_count ASC;