表1 MBM_CASE
表2 MOS_ORGANIZATION
統(tǒng)計(jì)主體表:表1仅偎,其中字段P_JUSTICE_BUREAU存儲(chǔ)的為 表2 的type_id = '255afee102374b60b770de3b601f0f0b'類型的id,需翻譯成name
select a.P_JUSTICE_BUREAU,b.P_JUSTICE_BUREAU_NAMER,count(*) as total from MBM_CASE as a
left join (select id,p_name as P_JUSTICE_BUREAU_NAMER from MOS_ORGANIZATION as b where type_id = '255afee102374b60b770de3b601f0f0b') as b on a.P_JUSTICE_BUREAU = b.id
where a.P_STATUS = 'VALID' AND a.P_CASE_STATUS != 'DRAFT' AND a.P_ACCEPTANCE_DATE BETWEEN '2017-01-01' AND '2017-12-31'
GROUP BY a.P_JUSTICE_BUREAU,b.P_JUSTICE_BUREAU_NAMER