parent
31f2813192
commit
1097ce5fce
@ -1,6 +0,0 @@
|
|||||||
SELECT count(distinct name)
|
|
||||||
FROM claimables
|
|
||||||
LEFT JOIN claims ON claimables.name = claims.val AND claimables.typ = claims.claim_type
|
|
||||||
WHERE claims.val IS NULL
|
|
||||||
AND claimables.typ = 'area'
|
|
||||||
AND claimables.name LIKE '%bay%';
|
|
@ -0,0 +1,15 @@
|
|||||||
|
drop table claimables;
|
||||||
|
create view if not exists claimables 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' 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
|
||||||
|
;
|
@ -0,0 +1,15 @@
|
|||||||
|
drop view claimables;
|
||||||
|
create table if not exists claimables 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' 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
|
||||||
|
;
|
Loading…
Reference in new issue