leading-project/dw/dws/dws_engine_equipment_inspect_task_m.sql

12 lines
601 B
MySQL
Raw Permalink 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
2024-07-23 21:40:49 +08:00
, sum(case when TaskStatue = 2 then 1 else 0 end) task_finish_num -- 完成数量
, count(*) task_num -- 任务数量
,sum(case when TaskStatue = 2 then 1 else 0 end) / count(*) * 100 as rate
2024-07-21 22:06:45 +08:00
from dwd_engine_equipment_inspection_task_d a
2024-07-23 21:40:49 +08:00
join (select distinct organ_code, organ_name, comm_id, comm_name from dim_organ_mapping) b
2024-07-21 22:06:45 +08:00
on a.CommId = b.comm_id
group by
organ_code, organ_name, comm_id, comm_name
, date_format(TaskEndTime, '%Y%m')