fix(db): refactor db/sql/update.sql

This commit is contained in:
dancingCycle 2023-08-31 19:36:01 +02:00
parent 79ce42f63e
commit 45222fbb96
1 changed files with 18 additions and 39 deletions

View File

@ -15,7 +15,7 @@ CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de AS
SELECT * FROM :schema.vw_gtfs_stops_lt_0 AS stops JOIN public.de_al2_w_ntags_smplcty10_20230818 AS de ON ST_Intersects(stops.the_geom, de.wkb_geometry) order by stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_not_de AS
SELECT * FROM :schema.vw_gtfs_stops_lt_0 AS stops_lt_0 WHERE NOT stops_lt_0.stop_id IN (SELECT stops_de.stop_id FROM :schema.vw_gtfs_stops_de AS stops_de);
SELECT * FROM :schema.vw_gtfs_stops_lt_0 AS stops_lt_0 WHERE stops_lt_0.stop_id NOT IN (SELECT stops_de.stop_id FROM :schema.vw_gtfs_stops_de AS stops_de);
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_hb AS
SELECT * FROM :schema.vw_gtfs_stops_lt_0 AS stops JOIN public.de_hb_al4_w_ntags_smplcty10_20230818 AS de_hb ON ST_Intersects(stops.the_geom, de_hb.wkb_geometry) order by stop_id;
@ -77,26 +77,24 @@ CREATE TABLE IF NOT EXISTS :schema.tbl_gtfs_stops_de_bw AS SELECT stop_id,stop_n
---get subset of stops in Germany and its states that do not comply with a proper Global ID
---create views
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_not_dhid AS SELECT * FROM :schema.tbl_gtfs_stops_de WHERE stop_id NOT IN (SELECT dhid FROM :schema_gtfs.stops_zhv) AND stop_id NOT LIKE '%:%:%' ORDER BY stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_not_dhid AS SELECT * FROM :schema.tbl_gtfs_stops_de WHERE stop_id NOT LIKE '%:%:%' ORDER BY stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_hb_not_dhid AS SELECT * FROM :schema.tbl_gtfs_stops_de_hb WHERE stop_id NOT IN (SELECT dhid FROM :schema_gtfs.stops_zhv) AND stop_id NOT LIKE '%:%:%' ORDER BY stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_hh_not_dhid AS SELECT * FROM :schema.tbl_gtfs_stops_de_hh WHERE stop_id NOT IN (SELECT dhid FROM :schema_gtfs.stops_zhv) AND stop_id NOT LIKE '%:%:%' ORDER BY stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_ni_not_dhid AS SELECT * FROM :schema.tbl_gtfs_stops_de_ni WHERE stop_id NOT IN (SELECT dhid FROM :schema_gtfs.stops_zhv) AND stop_id NOT LIKE '%:%:%' ORDER BY stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_sh_not_dhid AS SELECT * FROM :schema.tbl_gtfs_stops_de_sh WHERE stop_id NOT IN (SELECT dhid FROM :schema_gtfs.stops_zhv) AND stop_id NOT LIKE '%:%:%' ORDER BY stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_mv_not_dhid AS SELECT * FROM :schema.tbl_gtfs_stops_de_mv WHERE stop_id NOT IN (SELECT dhid FROM :schema_gtfs.stops_zhv) AND stop_id NOT LIKE '%:%:%' ORDER BY stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_bb_not_dhid AS SELECT * FROM :schema.tbl_gtfs_stops_de_bb WHERE stop_id NOT IN (SELECT dhid FROM :schema_gtfs.stops_zhv) AND stop_id NOT LIKE '%:%:%' ORDER BY stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_st_not_dhid AS SELECT * FROM :schema.tbl_gtfs_stops_de_st WHERE stop_id NOT IN (SELECT dhid FROM :schema_gtfs.stops_zhv) AND stop_id NOT LIKE '%:%:%' ORDER BY stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_be_not_dhid AS SELECT * FROM :schema.tbl_gtfs_stops_de_be WHERE stop_id NOT IN (SELECT dhid FROM :schema_gtfs.stops_zhv) AND stop_id NOT LIKE '%:%:%' ORDER BY stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_nw_not_dhid AS SELECT * FROM :schema.tbl_gtfs_stops_de_nw WHERE stop_id NOT IN (SELECT dhid FROM :schema_gtfs.stops_zhv) AND stop_id NOT LIKE '%:%:%' ORDER BY stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_he_not_dhid AS SELECT * FROM :schema.tbl_gtfs_stops_de_he WHERE stop_id NOT IN (SELECT dhid FROM :schema_gtfs.stops_zhv) AND stop_id NOT LIKE '%:%:%' ORDER BY stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_sn_not_dhid AS SELECT * FROM :schema.tbl_gtfs_stops_de_sn WHERE stop_id NOT IN (SELECT dhid FROM :schema_gtfs.stops_zhv) AND stop_id NOT LIKE '%:%:%' ORDER BY stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_th_not_dhid AS SELECT * FROM :schema.tbl_gtfs_stops_de_th WHERE stop_id NOT IN (SELECT dhid FROM :schema_gtfs.stops_zhv) AND stop_id NOT LIKE '%:%:%' ORDER BY stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_rp_not_dhid AS SELECT * FROM :schema.tbl_gtfs_stops_de_rp WHERE stop_id NOT IN (SELECT dhid FROM :schema_gtfs.stops_zhv) AND stop_id NOT LIKE '%:%:%' ORDER BY stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_sl_not_dhid AS SELECT * FROM :schema.tbl_gtfs_stops_de_sl WHERE stop_id NOT IN (SELECT dhid FROM :schema_gtfs.stops_zhv) AND stop_id NOT LIKE '%:%:%' ORDER BY stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_by_not_dhid AS SELECT * FROM :schema.tbl_gtfs_stops_de_by WHERE stop_id NOT IN (SELECT dhid FROM :schema_gtfs.stops_zhv) AND stop_id NOT LIKE '%:%:%' ORDER BY stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_bw_not_dhid AS SELECT * FROM :schema.tbl_gtfs_stops_de_bw WHERE stop_id NOT IN (SELECT dhid FROM :schema_gtfs.stops_zhv) AND stop_id NOT LIKE '%:%:%' ORDER BY stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_hb_not_dhid AS SELECT * FROM :schema.tbl_gtfs_stops_de_hb WHERE stop_id NOT LIKE '%:%:%' ORDER BY stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_hh_not_dhid AS SELECT * FROM :schema.tbl_gtfs_stops_de_hh WHERE stop_id NOT LIKE '%:%:%' ORDER BY stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_ni_not_dhid AS SELECT * FROM :schema.tbl_gtfs_stops_de_ni WHERE stop_id NOT LIKE '%:%:%' ORDER BY stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_sh_not_dhid AS SELECT * FROM :schema.tbl_gtfs_stops_de_sh WHERE stop_id NOT LIKE '%:%:%' ORDER BY stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_mv_not_dhid AS SELECT * FROM :schema.tbl_gtfs_stops_de_mv WHERE stop_id NOT LIKE '%:%:%' ORDER BY stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_bb_not_dhid AS SELECT * FROM :schema.tbl_gtfs_stops_de_bb WHERE stop_id NOT LIKE '%:%:%' ORDER BY stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_st_not_dhid AS SELECT * FROM :schema.tbl_gtfs_stops_de_st WHERE stop_id NOT LIKE '%:%:%' ORDER BY stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_be_not_dhid AS SELECT * FROM :schema.tbl_gtfs_stops_de_be WHERE stop_id NOT LIKE '%:%:%' ORDER BY stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_nw_not_dhid AS SELECT * FROM :schema.tbl_gtfs_stops_de_nw WHERE stop_id NOT LIKE '%:%:%' ORDER BY stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_he_not_dhid AS SELECT * FROM :schema.tbl_gtfs_stops_de_he WHERE stop_id NOT LIKE '%:%:%' ORDER BY stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_sn_not_dhid AS SELECT * FROM :schema.tbl_gtfs_stops_de_sn WHERE stop_id NOT LIKE '%:%:%' ORDER BY stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_th_not_dhid AS SELECT * FROM :schema.tbl_gtfs_stops_de_th WHERE stop_id NOT LIKE '%:%:%' ORDER BY stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_rp_not_dhid AS SELECT * FROM :schema.tbl_gtfs_stops_de_rp WHERE stop_id NOT LIKE '%:%:%' ORDER BY stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_sl_not_dhid AS SELECT * FROM :schema.tbl_gtfs_stops_de_sl WHERE stop_id NOT LIKE '%:%:%' ORDER BY stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_by_not_dhid AS SELECT * FROM :schema.tbl_gtfs_stops_de_by WHERE stop_id NOT LIKE '%:%:%' ORDER BY stop_id;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stops_de_bw_not_dhid AS SELECT * FROM :schema.tbl_gtfs_stops_de_bw WHERE stop_id NOT LIKE '%:%:%' ORDER BY stop_id;
---create tables
CREATE TABLE IF NOT EXISTS :schema.tbl_gtfs_stops_de_not_dhid AS SELECT stop_id,stop_name,stop_lat,stop_lon,the_geom FROM :schema.vw_gtfs_stops_de_not_dhid;
@ -127,16 +125,12 @@ CREATE OR REPLACE VIEW :schema.vw_gtfs_stop_names_de_bw_part_dhid AS SELECT * FR
CREATE TABLE IF NOT EXISTS :schema.tbl_gtfs_stop_names_de_bw_part_dhid AS SELECT * FROM :schema.vw_gtfs_stop_names_de_bw_part_dhid;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stop_names_de_by_part_dhid AS SELECT * FROM (SELECT count(stop_id) AS count_id, count(stop_id) filter (WHERE stop_id NOT LIKE '%:%:%') AS count_no_dhid, count(stop_id) filter (WHERE stop_id LIKE '%:%:%') AS count_dhid, stop_name FROM :schema.tbl_gtfs_stops_de_by GROUP BY stop_name ORDER BY count_id DESC) AS foo WHERE count_id != count_dhid AND count_id != count_no_dhid;
CREATE TABLE IF NOT EXISTS :schema.tbl_gtfs_stop_names_de_by_part_dhid AS SELECT * FROM :schema.vw_gtfs_stop_names_de_by_part_dhid;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stop_names_de_hb_part_dhid AS SELECT * FROM (SELECT count(stop_id) AS count_id, count(stop_id) filter (WHERE stop_id NOT LIKE '%:%:%') AS count_no_dhid, count(stop_id) filter (WHERE stop_id LIKE '%:%:%') AS count_dhid, stop_name FROM :schema.tbl_gtfs_stops_de_hb GROUP BY stop_name ORDER BY count_id DESC) AS foo WHERE count_id != count_dhid AND count_id != count_no_dhid;
CREATE TABLE IF NOT EXISTS :schema.tbl_gtfs_stop_names_de_hb_part_dhid AS SELECT * FROM :schema.vw_gtfs_stop_names_de_hb_part_dhid;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stop_names_de_he_part_dhid AS SELECT * FROM (SELECT count(stop_id) AS count_id, count(stop_id) filter (WHERE stop_id NOT LIKE '%:%:%') AS count_no_dhid, count(stop_id) filter (WHERE stop_id LIKE '%:%:%') AS count_dhid, stop_name FROM :schema.tbl_gtfs_stops_de_he GROUP BY stop_name ORDER BY count_id DESC) AS foo WHERE count_id != count_dhid AND count_id != count_no_dhid;
CREATE TABLE IF NOT EXISTS :schema.tbl_gtfs_stop_names_de_he_part_dhid AS SELECT * FROM :schema.vw_gtfs_stop_names_de_he_part_dhid;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stop_names_de_hh_part_dhid AS SELECT * FROM (SELECT count(stop_id) AS count_id, count(stop_id) filter (WHERE stop_id NOT LIKE '%:%:%') AS count_no_dhid, count(stop_id) filter (WHERE stop_id LIKE '%:%:%') AS count_dhid, stop_name FROM :schema.tbl_gtfs_stops_de_hh GROUP BY stop_name ORDER BY count_id DESC) AS foo WHERE count_id != count_dhid AND count_id != count_no_dhid;
CREATE TABLE IF NOT EXISTS :schema.tbl_gtfs_stop_names_de_hh_part_dhid AS SELECT * FROM :schema.vw_gtfs_stop_names_de_hh_part_dhid;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stop_names_de_mv_part_dhid AS SELECT * FROM (SELECT count(stop_id) AS count_id, count(stop_id) filter (WHERE stop_id NOT LIKE '%:%:%') AS count_no_dhid, count(stop_id) filter (WHERE stop_id LIKE '%:%:%') AS count_dhid, stop_name FROM :schema.tbl_gtfs_stops_de_mv GROUP BY stop_name ORDER BY count_id DESC) AS foo WHERE count_id != count_dhid AND count_id != count_no_dhid;
CREATE TABLE IF NOT EXISTS :schema.tbl_gtfs_stop_names_de_mv_part_dhid AS SELECT * FROM :schema.vw_gtfs_stop_names_de_mv_part_dhid;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stop_names_de_ni_part_dhid AS SELECT * FROM (SELECT count(stop_id) AS count_id, count(stop_id) filter (WHERE stop_id NOT LIKE '%:%:%') AS count_no_dhid, count(stop_id) filter (WHERE stop_id LIKE '%:%:%') AS count_dhid, stop_name FROM :schema.tbl_gtfs_stops_de_ni GROUP BY stop_name ORDER BY count_id DESC) AS foo WHERE count_id != count_dhid AND count_id != count_no_dhid;
@ -159,48 +153,33 @@ CREATE TABLE IF NOT EXISTS :schema.tbl_gtfs_stop_names_de_th_part_dhid AS SELECT
---get stop names with no Global ID availability
CREATE OR REPLACE VIEW :schema.vw_gtfs_stop_names_de_bb_no_dhid AS SELECT * FROM (SELECT count(stop_id) AS count_id, count(stop_id) filter (WHERE stop_id NOT LIKE '%:%:%') AS count_no_dhid, count(stop_id) filter (WHERE stop_id LIKE '%:%:%') AS count_dhid, stop_name FROM :schema.tbl_gtfs_stops_de_bb GROUP BY stop_name ORDER BY count_id DESC) AS foo WHERE count_id = count_no_dhid;
CREATE TABLE IF NOT EXISTS :schema.tbl_gtfs_stop_names_de_bb_no_dhid AS SELECT * FROM :schema.vw_gtfs_stop_names_de_bb_no_dhid;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stop_names_de_be_no_dhid AS SELECT * FROM (SELECT count(stop_id) AS count_id, count(stop_id) filter (WHERE stop_id NOT LIKE '%:%:%') AS count_no_dhid, count(stop_id) filter (WHERE stop_id LIKE '%:%:%') AS count_dhid, stop_name FROM :schema.tbl_gtfs_stops_de_be GROUP BY stop_name ORDER BY count_id DESC) AS foo WHERE count_id = count_no_dhid;
CREATE TABLE IF NOT EXISTS :schema.tbl_gtfs_stop_names_de_be_no_dhid AS SELECT * FROM :schema.vw_gtfs_stop_names_de_be_no_dhid;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stop_names_de_bw_no_dhid AS SELECT * FROM (SELECT count(stop_id) AS count_id, count(stop_id) filter (WHERE stop_id NOT LIKE '%:%:%') AS count_no_dhid, count(stop_id) filter (WHERE stop_id LIKE '%:%:%') AS count_dhid, stop_name FROM :schema.tbl_gtfs_stops_de_bw GROUP BY stop_name ORDER BY count_id DESC) AS foo WHERE count_id = count_no_dhid;
CREATE TABLE IF NOT EXISTS :schema.tbl_gtfs_stop_names_de_bw_no_dhid AS SELECT * FROM :schema.vw_gtfs_stop_names_de_bw_no_dhid;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stop_names_de_by_no_dhid AS SELECT * FROM (SELECT count(stop_id) AS count_id, count(stop_id) filter (WHERE stop_id NOT LIKE '%:%:%') AS count_no_dhid, count(stop_id) filter (WHERE stop_id LIKE '%:%:%') AS count_dhid, stop_name FROM :schema.tbl_gtfs_stops_de_by GROUP BY stop_name ORDER BY count_id DESC) AS foo WHERE count_id = count_no_dhid;
CREATE TABLE IF NOT EXISTS :schema.tbl_gtfs_stop_names_de_by_no_dhid AS SELECT * FROM :schema.vw_gtfs_stop_names_de_by_no_dhid;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stop_names_de_hb_no_dhid AS SELECT * FROM (SELECT count(stop_id) AS count_id, count(stop_id) filter (WHERE stop_id NOT LIKE '%:%:%') AS count_no_dhid, count(stop_id) filter (WHERE stop_id LIKE '%:%:%') AS count_dhid, stop_name FROM :schema.tbl_gtfs_stops_de_hb GROUP BY stop_name ORDER BY count_id DESC) AS foo WHERE count_id = count_no_dhid;
CREATE TABLE IF NOT EXISTS :schema.tbl_gtfs_stop_names_de_hb_no_dhid AS SELECT * FROM :schema.vw_gtfs_stop_names_de_hb_no_dhid;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stop_names_de_he_no_dhid AS SELECT * FROM (SELECT count(stop_id) AS count_id, count(stop_id) filter (WHERE stop_id NOT LIKE '%:%:%') AS count_no_dhid, count(stop_id) filter (WHERE stop_id LIKE '%:%:%') AS count_dhid, stop_name FROM :schema.tbl_gtfs_stops_de_he GROUP BY stop_name ORDER BY count_id DESC) AS foo WHERE count_id = count_no_dhid;
CREATE TABLE IF NOT EXISTS :schema.tbl_gtfs_stop_names_de_he_no_dhid AS SELECT * FROM :schema.vw_gtfs_stop_names_de_he_no_dhid;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stop_names_de_hh_no_dhid AS SELECT * FROM (SELECT count(stop_id) AS count_id, count(stop_id) filter (WHERE stop_id NOT LIKE '%:%:%') AS count_no_dhid, count(stop_id) filter (WHERE stop_id LIKE '%:%:%') AS count_dhid, stop_name FROM :schema.tbl_gtfs_stops_de_hh GROUP BY stop_name ORDER BY count_id DESC) AS foo WHERE count_id = count_no_dhid;
CREATE TABLE IF NOT EXISTS :schema.tbl_gtfs_stop_names_de_hh_no_dhid AS SELECT * FROM :schema.vw_gtfs_stop_names_de_hh_no_dhid;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stop_names_de_mv_no_dhid AS SELECT * FROM (SELECT count(stop_id) AS count_id, count(stop_id) filter (WHERE stop_id NOT LIKE '%:%:%') AS count_no_dhid, count(stop_id) filter (WHERE stop_id LIKE '%:%:%') AS count_dhid, stop_name FROM :schema.tbl_gtfs_stops_de_mv GROUP BY stop_name ORDER BY count_id DESC) AS foo WHERE count_id = count_no_dhid;
CREATE TABLE IF NOT EXISTS :schema.tbl_gtfs_stop_names_de_mv_no_dhid AS SELECT * FROM :schema.vw_gtfs_stop_names_de_mv_no_dhid;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stop_names_de_ni_no_dhid AS SELECT * FROM (SELECT count(stop_id) AS count_id, count(stop_id) filter (WHERE stop_id NOT LIKE '%:%:%') AS count_no_dhid, count(stop_id) filter (WHERE stop_id LIKE '%:%:%') AS count_dhid, stop_name FROM :schema.tbl_gtfs_stops_de_ni GROUP BY stop_name ORDER BY count_id DESC) AS foo WHERE count_id = count_no_dhid;
CREATE TABLE IF NOT EXISTS :schema.tbl_gtfs_stop_names_de_ni_no_dhid AS SELECT * FROM :schema.vw_gtfs_stop_names_de_ni_no_dhid;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stop_names_de_nw_no_dhid AS SELECT * FROM (SELECT count(stop_id) AS count_id, count(stop_id) filter (WHERE stop_id NOT LIKE '%:%:%') AS count_no_dhid, count(stop_id) filter (WHERE stop_id LIKE '%:%:%') AS count_dhid, stop_name FROM :schema.tbl_gtfs_stops_de_nw GROUP BY stop_name ORDER BY count_id DESC) AS foo WHERE count_id = count_no_dhid;
CREATE TABLE IF NOT EXISTS :schema.tbl_gtfs_stop_names_de_nw_no_dhid AS SELECT * FROM :schema.vw_gtfs_stop_names_de_nw_no_dhid;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stop_names_de_rp_no_dhid AS SELECT * FROM (SELECT count(stop_id) AS count_id, count(stop_id) filter (WHERE stop_id NOT LIKE '%:%:%') AS count_no_dhid, count(stop_id) filter (WHERE stop_id LIKE '%:%:%') AS count_dhid, stop_name FROM :schema.tbl_gtfs_stops_de_rp GROUP BY stop_name ORDER BY count_id DESC) AS foo WHERE count_id = count_no_dhid;
CREATE TABLE IF NOT EXISTS :schema.tbl_gtfs_stop_names_de_rp_no_dhid AS SELECT * FROM :schema.vw_gtfs_stop_names_de_rp_no_dhid;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stop_names_de_sh_no_dhid AS SELECT * FROM (SELECT count(stop_id) AS count_id, count(stop_id) filter (WHERE stop_id NOT LIKE '%:%:%') AS count_no_dhid, count(stop_id) filter (WHERE stop_id LIKE '%:%:%') AS count_dhid, stop_name FROM :schema.tbl_gtfs_stops_de_sh GROUP BY stop_name ORDER BY count_id DESC) AS foo WHERE count_id = count_no_dhid;
CREATE TABLE IF NOT EXISTS :schema.tbl_gtfs_stop_names_de_sh_no_dhid AS SELECT * FROM :schema.vw_gtfs_stop_names_de_sh_no_dhid;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stop_names_de_sl_no_dhid AS SELECT * FROM (SELECT count(stop_id) AS count_id, count(stop_id) filter (WHERE stop_id NOT LIKE '%:%:%') AS count_no_dhid, count(stop_id) filter (WHERE stop_id LIKE '%:%:%') AS count_dhid, stop_name FROM :schema.tbl_gtfs_stops_de_sl GROUP BY stop_name ORDER BY count_id DESC) AS foo WHERE count_id = count_no_dhid;
CREATE TABLE IF NOT EXISTS :schema.tbl_gtfs_stop_names_de_sl_no_dhid AS SELECT * FROM :schema.vw_gtfs_stop_names_de_sl_no_dhid;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stop_names_de_sn_no_dhid AS SELECT * FROM (SELECT count(stop_id) AS count_id, count(stop_id) filter (WHERE stop_id NOT LIKE '%:%:%') AS count_no_dhid, count(stop_id) filter (WHERE stop_id LIKE '%:%:%') AS count_dhid, stop_name FROM :schema.tbl_gtfs_stops_de_sn GROUP BY stop_name ORDER BY count_id DESC) AS foo WHERE count_id = count_no_dhid;
CREATE TABLE IF NOT EXISTS :schema.tbl_gtfs_stop_names_de_sn_no_dhid AS SELECT * FROM :schema.vw_gtfs_stop_names_de_sn_no_dhid;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stop_names_de_st_no_dhid AS SELECT * FROM (SELECT count(stop_id) AS count_id, count(stop_id) filter (WHERE stop_id NOT LIKE '%:%:%') AS count_no_dhid, count(stop_id) filter (WHERE stop_id LIKE '%:%:%') AS count_dhid, stop_name FROM :schema.tbl_gtfs_stops_de_st GROUP BY stop_name ORDER BY count_id DESC) AS foo WHERE count_id = count_no_dhid;
CREATE TABLE IF NOT EXISTS :schema.tbl_gtfs_stop_names_de_st_no_dhid AS SELECT * FROM :schema.vw_gtfs_stop_names_de_st_no_dhid;
CREATE OR REPLACE VIEW :schema.vw_gtfs_stop_names_de_th_no_dhid AS SELECT * FROM (SELECT count(stop_id) AS count_id, count(stop_id) filter (WHERE stop_id NOT LIKE '%:%:%') AS count_no_dhid, count(stop_id) filter (WHERE stop_id LIKE '%:%:%') AS count_dhid, stop_name FROM :schema.tbl_gtfs_stops_de_th GROUP BY stop_name ORDER BY count_id DESC) AS foo WHERE count_id = count_no_dhid;
CREATE TABLE IF NOT EXISTS :schema.tbl_gtfs_stop_names_de_th_no_dhid AS SELECT * FROM :schema.vw_gtfs_stop_names_de_th_no_dhid;