FRzengjie(提问者)select a.z_org_id,a.Z_CHECK_RESULT,sum(z_day_valus),sum(z_weeks_valus),sum(z_month_valus)
from
(select a.z_org_id,b.Z_CHECK_RESULT,a.z_org_nm,count(a.id_key)z_day_valus,0 z_weeks_valus,0 z_month_valus from zlv_check_note_m a,zlv_check_note_l b
where b.Z_CHECK_RESULT in(500074,500075,500076,500077,510076)
and a.id_key=b.vou_id
and b.Z_CHECK_DATE=\'2020-03-08\'
group by a.z_org_id,b.Z_CHECK_RESULT,a.z_org_nm
union all
select a.z_org_id,b.Z_CHECK_RESULT,a.z_org_nm,0,count(a.id_key)z_weeks_valus,0 z_month_valus from zlv_check_note_m a,zlv_check_note_l b,ZLT_WEEKLY_DETAIL c
where b.Z_CHECK_RESULT in(500074,500075,500076,500077,510076)
and a.id_key=b.vou_id
and b.z_weeks=c.z_weeks
and c.z_DATE=\'2020-03-08\'
group by a.z_org_id,b.Z_CHECK_RESULT,a.z_org_nm
union all
select a.z_org_id,b.Z_CHECK_RESULT,a.z_org_nm,0 z_day_valus,0 z_weeks_valus,count(a.id_key) z_month_valus from zlv_check_note_m a,zlv_check_note_l b
where b.Z_CHECK_RESULT in(500074,500075,500076,500077,510076)
and a.id_key=b.vou_id
and substr(b.Z_check_DATE,0,7)=substr(\'2020-03-08\',0,7)
group by a.z_org_id,b.Z_CHECK_RESULT,a.z_org_nm) a
group by a.z_org_id,a.Z_CHECK_RESULT,a.z_org_nm
FRzengjie(提问者)我菜的恼火,试了几次,不行,麻烦大佬。
select a.z_org_id,dbms_lob.substr(wmsys.wm_concat(decode(a.Z_CHECK_RESULT,\'500074\',\'怀孕\',\'500075\',\'返情\',\'500076\',\'流产\',\'500077\',\'空胎\',\'510076\',\'隐流\'))) Z_CHECK_RESULT,dbms_lob.substr(wmsys.wm_concat(z_day_valus)),dbms_lob.substr(wmsys.wm_concat(z_weeks_valus)),dbms_lob.substr(wmsys.wm_concat(z_month_valus))
from
(select a.z_org_id,b.Z_CHECK_RESULT,a.z_org_nm,count(a.id_key)z_day_valus,0 z_weeks_valus,0 z_month_valus from zlv_check_note_m a,zlv_check_note_l b
where b.Z_CHECK_RESULT in(500074,500075,500076,500077,510076)
and a.id_key=b.vou_id
and b.Z_CHECK_DATE=\'2020-03-08\'
group by a.z_org_id,b.Z_CHECK_RESULT,a.z_org_nm
union all
select a.z_org_id,b.Z_CHECK_RESULT,a.z_org_nm,0,count(a.id_key)z_weeks_valus,0 z_month_valus from zlv_check_note_m a,zlv_check_note_l b,ZLT_WEEKLY_DETAIL c
where b.Z_CHECK_RESULT in(500074,500075,500076,500077,510076)
and a.id_key=b.vou_id
and b.z_weeks=c.z_weeks
and c.z_DATE=\'2020-03-08\'
group by a.z_org_id,b.Z_CHECK_RESULT,a.z_org_nm
union all
select a.z_org_id,b.Z_CHECK_RESULT,a.z_org_nm,0 z_day_valus,0 z_weeks_valus,count(a.id_key) z_month_valus from zlv_check_note_m a,zlv_check_note_l b
where b.Z_CHECK_RESULT in(500074,500075,500076,500077,510076)
and a.id_key=b.vou_id
and substr(b.Z_check_DATE,0,7)=substr(\'2020-03-08\',0,7)
group by a.z_org_id,b.Z_CHECK_RESULT,a.z_org_nm) a
group by a.z_org_id--,a.Z_CHECK_RESULT,a.z_org_nm