我目前有一种情况,当表达式向我显示员工执行的特定类型任务的总数。
select
ptt.user_id
/*System Generated Counts*/ ,
count(distinct case
when menu_optn_name in ('Cycle Cnt {Active}','Cycle Cnt {Reserve}','Cycle Cnt Reserve (Tasking)') and task_id is not null then tran_nbr
else null
end) "Task Cnt"
/*Spot Counts*/ ,
count(distinct case
when menu_optn_name in ('Cycle Cnt {Active}','Cycle Cnt {Reserve}') and task_id is null then tran_nbr
else null
end) "Spot_Counts",
count(distinct case
when menu_optn_name in ('Cycle Cnt {Active}','Cycle Cnt {Reserve}','Cycle Cnt Reserve (Tasking)') and task_id is not null then tran_nbr
when menu_optn_name in ('Cycle Cnt {Active}','Cycle Cnt {Reserve}','Cycle Cnt Reserve (Tasking)') and task_id is null then tran_nbr
else null
end) "Total_locations",
count(case
when menu_optn_name in ('Cycle Cnt {Active}','Cycle Cnt {Reserve}','Cycle Cnt Reserve (Tasking)') and task_id is not null then tran_nbr
when menu_optn_name in ('Cycle Cnt {Active}','Cycle Cnt {Reserve}','Cycle Cnt Reserve (Tasking)') and task_id is null then tran_nbr
else null
end) "Total_Cases"
from PROD_TRKG_TRAN ptt
join cd_master cm on
ptt.cd_master_id = cm.cd_master_id
and co = 'MEDT'
and div = '002'
and ptt.USER_ID in ('ARAMOS1','ECHAMBERS','SCOUNCIL','STORTEROTOT','TGABRIEL','JORTIZ','FGUTIERREZ','CMALDONADO','LLEE1')
and ptt.create_date_time >=
/*Today*/ trunc(sysdate)
--/*This Week*/ trunc(sysdate-(to_char(sysdate,'D')-1))
--/*This Month*/ trunc(sysdate)-(to_char(sysdate,'DD')-1)
--/*Date Range*/ '&FromDate' and ptt.create_date_time-1 < '&ToDate'
group by ptt.user_id
以上是我当前使用的SQL,在计算表达式时,前2种情况是根据特定选择器计算员工有多少个位置为空或不为空。 接下来的2种情况,当表达式将二者组合在一起时,可以为您提供一夜中某个人所计数的总的不同位置,下一个表达式显示您所计数的总病例数,有时某个位置中有不止一个案例。 / p>
我在这里的目标是将地点和案件的总数除以7 1/2小时,这样我就可以看到一天中每小时平均有多少个人。 我尝试了一些没有运气的东西。可能有人可以提供帮助。 预先谢谢你。