select a.id , a.ajmc case_name -- 案件名称 , d.pqmc district_name -- 片区名称 , b.xmmc project_name -- 项目名称 , a.sszy belong_resource -- 所属资源 , a.laje filing_amt -- 立案金额 , a.ysqkje rec_outstand_amt -- 应收欠款金额 , a.ysqkwyj rec_outstand_def_penalty -- 应收欠款违约金 , a.ssqkje paid_outstand_amt -- 实收欠款金额 , a.ssqkwyj paid_outstand_def_penalty -- 实收欠款违约金 , 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 '强制退回中' end status -- 状态 , case when a.ajlx = 0 then '诉讼' else '非诉' end case_type -- 案件类型 , case when a.qfyylx = 0 then '空置房' when a.qfyylx = 1 then '房屋质量问题' when a.qfyylx = 2 then '开司遗留问题(除房屋质量)' when a.qfyylx = 3 then '未取得有效联系' when a.qfyylx = 4 then '对物业服务质量、收费依据有异议' when a.qfyylx = 5 then '无理由恶意欠费' when a.qfyylx = 6 then '业主其他原因' end outstand_reason_type -- 欠费原因类型 , a.wjsj -- 完结时间 , case when a.ajjz = 0 then '电话催收' when a.ajjz = 1 then '短信催收' when a.ajjz = 2 then '函件催收' when a.ajjz = 3 then '律师函催收' when a.ajjz = 4 then '仲裁立案' when a.ajjz = 5 then '仲裁开庭' when a.ajjz = 6 then '仲裁中和解、调解' when a.ajjz = 7 then '仲裁裁决' when a.ajjz = 8 then '一审网上立案' when a.ajjz = 9 then '诉前调解' when a.ajjz = 10 then '一审立案' when a.ajjz = 11 then '一审开庭' when a.ajjz = 12 then '一审诉中和解/调解' when a.ajjz = 13 then '一审判决' when a.ajjz = 14 then '上诉' when a.ajjz = 15 then '二审立案审开庭' when a.ajjz = 16 then '二审诉中和解/调解' when a.ajjz = 17 then '二审判决' when a.ajjz = 18 then '发回重审' when a.ajjz = 19 then '再审立案' when a.ajjz = 20 then '再审开庭' when a.ajjz = 21 then '再审诉中和解/调解' when a.ajjz = 22 then '执行终止本次执行' when a.ajjz = 23 then '结案' end case_stage , a.csdw collect_unit , a.sfww is_external from ods_oa_uf_wy_aj_d a left join (select id, xmmc 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