-- ======================================
-- 经销商维度表
-- ======================================
select
     a.deal_code          AS deal_code      -- 经销商编码
    ,b.deal_name          AS deal_name      -- 经销商名称
    ,a.city_unit_code     AS city_unit_code -- 城市单元编码
    ,a.city_unit_name     AS city_unit_name -- 城市单元名称
    ,a.office_code        AS office_code    -- 办事处编码
    ,a.office_name        AS office_name    -- 办事处名称
    ,a.region_code        AS region_code    -- 大区编码
    ,a.region_name        AS region_name    -- 大区名称
    ,a.bu_code            AS bu_code        -- 事业部编码
    ,a.bu_name            AS bu_name        -- 事业部名称
    ,b.country_code       AS country_code   -- 国家编码
    ,b.country_name       AS country_name   -- 国别
    ,b.province_code      AS province_code  -- 省级编码
    ,b.province_name      AS province_name  -- 注册地所在省
    ,b.city_code          AS city_code      -- 市级编码
    ,b.city_name          AS city_name      -- 注册地所在市
    ,b.county_code        AS county_code    -- 县级编码
    ,b.county_name        AS county_name    -- 注册地所在县
from dwr.dim_dealer_administer a
left join dwr.dim_dealer b
on a.deal_code=b.deal_code
where a.enabled_status=1
  and a.region_name !~'停用'
  and a.office_name !~'停用'
