From b75539416aa466cea00fecb80f6d830a34b73a5d Mon Sep 17 00:00:00 2001 From: William Perron Date: Fri, 5 Jan 2024 14:35:13 -0500 Subject: [PATCH] tmp --- migrations/test.sql | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 migrations/test.sql diff --git a/migrations/test.sql b/migrations/test.sql new file mode 100644 index 0000000..863c3db --- /dev/null +++ b/migrations/test.sql @@ -0,0 +1,14 @@ +create view if not exists prov_by_type as + with + trades as (select distinct trade_node from provinces where trade_node != ''), + areas as (select distinct area from provinces where area != ''), + regions as (select distinct region from provinces where region != '') + select 'trade_node' as typ, provinces.trade_node as name, name as province, id + from provinces inner join trades on trades.trade_node = provinces.trade_node + union + select 'area' as typ, provinces.area as name, name as province, id + from provinces inner join areas on areas.area = provinces.area + union + select 'region' as typ, provinces.region as name, name as province, id + from provinces inner join regions on regions.region = provinces.region +;