0

我在 Oracle Apex 11.1 上有这段代码:

select r.s_manager_id,r.s_manager_nam,count(distinct(emp_id))Total_Employees,
    round((SUM(decode(bcoe,'y',1,0))/count(bcoe))*100,2)||'%'bcoe,
    round((SUM(decode(ecp,'y',1,0))/count(ecp))*100,2)||'%'ecp,
    round((SUM(decode(leave,'y',1,0))/count(leave))*100,2)||'%'leave,
    round((SUM(decode(eud,'y',1,0))/count(eud))*100,2)||'%'eud,
    round((SUM(decode(parking,'y',1,0))/count(parking))*100,2)||'%'parking,
    round((SUM(decode(building,'y',1,0))/count(building))*100,2)||'%'building
    from s_manager r,cmanager c,compliancetype t
    where r.s_manager_id = c.s_manager_id
        AND c.s_manager_id = t.s_manager_id
        AND month = 'Feb'
     GROUP BY r.s_manager_id,r.s_manager_nam 

它计算不同类型的合规性,但ecp应该bcoe每年计算一次。如何在 Oracle Apex 中做到这一点?然后leave应该按季度计算;怎么做?

4

1 回答 1

0

这些中的每一个

round((SUM(decode(FIELD,'y',1,0))/count(FIELD))*100,2)||'%'FIELD

可以简化为

round(AVG(decode(FIELD,'y',1,0))*100,2)||'%'FIELD

对于 Quarterly/Yearly,如果您要显示的年份数据month = 'Dec'在 3 月、6 月等月份,那么您不需要转到 Analytics。

只需以这种方式包装计算字段以获得季度数据。

case when month in ('Mar', 'Jun', 'Sep', 'Dec') then 
     round(AVG(decode(leave,'y',1,0))*100,2)||'%'leave
else 0
end
于 2012-08-08T08:51:41.983 回答