leading-project/dw/dws/dws_engine_equipment_inspect_task_m.sql

11 lines
489 B
MySQL
Raw Normal View History

2024-07-21 22:06:45 +08:00
select
organ_code, organ_name, comm_id, comm_name
, date_format(TaskEndTime, '%Y%m') task_ym
, sum(case when TaskStatue = 2 then 1 else 0 end) task_finish_num
, count(*) task_num
from dwd_engine_equipment_inspection_task_d a
left join (select distinct organ_code, organ_name, comm_id, comm_name from dim_organ_mapping) b
on a.CommId = b.comm_id
group by
organ_code, organ_name, comm_id, comm_name
, date_format(TaskEndTime, '%Y%m')