9 lines
516 B
SQL
9 lines
516 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_rts_cnt CASCADE;
|
|
CREATE OR REPLACE VIEW :schema.vw_rts_cnt AS SELECT gncy_rts.agency_id, gncy_rts.agency_name, count(DISTINCT gncy_rts.route_id) AS rts_cnt FROM :schema.vw_join_gncy_rts AS gncy_rts GROUP BY gncy_rts.agency_id, gncy_rts.agency_name ORDER BY rts_cnt ASC;
|