select
    a.id
     , a.zt status_id -- 状态id
     , case when a.zt = 0 then '正常'
            when a.zt = 1 then '待移交'
            when a.zt = 2 then '不移交'
            when a.zt = 3 then '不移交申请中'
            when a.zt = 4 then '非诉移交中'
            when a.zt = 5 then '诉讼移交中'
            when a.zt = 6 then '待诉讼处理'
            when a.zt = 7 then '待非诉处理'
            when a.zt = 8 then '催收中'
            when a.zt = 9 then '完结'
            when a.zt = 10 then '终本'
            when a.zt = 11 then '强制退回中'
    end status_name -- 状态名称
     , a.kxmc payment_name -- 款项名称
     , a.sszy belong_resource -- 所属资源
     , a.ssxm project_id -- 项目id
     , b.xmmc project_name -- 项目名称
     , d.pqbm district_code -- 片区id
     , d.pqmc district_name -- 片区名称
     , a.fyrq fee_date -- 费用日期
     , a.qfje owed_amt -- 欠费金额
     , a.yjje trans_amt -- 移交金额
     , b.xmbm project_code -- 项目编码
from ods_oa_uf_wy_qf_d a
         left join (select id, xmmc, xmbm from ods_oa_uf_wy_xm_d) b -- 项目
                   on a.ssxm = b.id
         left join (select id, left(pqbm,4) pqbm from ods_oa_uf_wy_pq_d where length(pqbm)=6) c -- 地区
                   on a.sspq = c.id
         left join (select pqbm, pqmc from ods_oa_uf_wy_pq_d where length(pqbm)=4) d -- 片区
                   on c.pqbm = d.pqbm