concat(TRUNCATE(((anInt-untreatedorders)/anInt)*100,1) ,'%')
(anInt-untreatedorders) 和 anInt 两个数值
实际操作
select *,concat(TRUNCATE(((anInt-untreatedorders)/anInt)*100,1) ,'%') percentage from (
select lw.delivery_name carriers,
(select count(*) from xx_logistics_waybill w1 where w1.delivery_name=lw.delivery_name) anInt,
(select count(*) from xx_logistics_waybill w3 where w3.delivery_name=lw.delivery_name and w3.assign_no=0) standby,
(select count(*) from xx_logistics_waybill w4 where w4.delivery_name=lw.delivery_name and w4.assign_no=1) carryon,
(select count(*) from xx_logistics_waybill w5 where w5.delivery_name=lw.delivery_name and w5.assign_no=4) pickupgoods,
(select count(*) from xx_logistics_waybill w6 where w6.delivery_name=lw.delivery_name and w6.assign_no=5) transportation,
(select count(*) from xx_logistics_waybill w7 where w7.delivery_name=lw.delivery_name and w7.assign_no=6) inspect,
(select count(1) from xx_logistics_waybill s where (TIMEDIFF(Now(), s.assign_time) > '00:30:00') and s.id in (SELECT s.id FROM xx_logistics_waybill s where s.status >= 1 and s.`status`<>2 and s.assign_no= 1 and s.create_date >= '2021-06-01 00:00:00' and s.delivery_name in(lw.delivery_name)) )untreatedorders
from xx_logistics_waybill lw group by lw.delivery_name
) temp