select a.*,
//转换函数,保留两位小数
convert(a.normalFinishDay/a.totalDay,decimal(10,2)) normalDayRate,
convert(a.normalFinishLead/a.totalLead,decimal(10,2)) normalLeadRate,
convert((a.normalFinishDay+a.normalFinishLead)/a.countEventAll,decimal(10,2)) countOverTimeRate,
(a.overTimeTotalDay+a.overTimeTotalLead) overTimeAll,
(a.normalFinishDay+a.normalFinishLead) normalAll
from (
select count(*) countEventAll,
//按条件得出总数
sum(case when complaintOrigin != 2236 then 1 else 0 end) totalDay,
sum(case when complaintOrigin = 2236 then 1 else 0 end) totalLead,
sum(case when isnofinish = 1 and complaintOrigin != 2236 then 1 else 0 end) overTimeTotalDay,
sum(case when isnofinish = 1 and complaintOrigin = 2236 then 1 else 0 end) overTimeTotalLead,
sum(case when isnofinish = 0 and complaintOrigin != 2236 then 1 else 0 end) normalFinishDay,
sum(case when isnofinish = 0 and complaintOrigin = 2236 then 1 else 0 end) normalFinishLead,
sum(case when isnofinish = 0 then 1 else 0 end) normalFinishTotal
from cc_casescoredetail where 1=1
type = 2427
)a
mysql中按条件求和并求出概率
最新推荐文章于 2024-04-26 09:28:43 发布