select
a.device_prefix as device_prefix,
sum(a.volume) as volume,
sum(a.volume)*100.0/c.volume as volume_percent,
cast(@total:=(@total+sum(a.volume)*100.0/c.volume) as decimal(20,5)) as cumlative_percent
from
djw_grpByMobileDevNet as a left join device_category_table as b on a.device_prefix=b.device_prefix,
(select sum(volume) as volume from djw_grpByMobileDevNet) as c,(select @total:=0) as d
where
b.device_prefix is null
or b.device_category=6
group by
a.device_prefix
order by
volume desc
limit 500;
有这样的写法吗?