select serviceid,area,ctype,sum(remain) as remain,sum(allfee) as allfee,statfortime from wap_nzstat_fee where company in(20,22,35) group by ctype,serviceid,statfortime with cube order by serviceid,statfortime,allfee;好像是这样
调试欢乐多
(
select serviceid,area,ctype,sum(remain) as remain,sum(allfee) as allfee,statfortime
from wap_nzstat_fee
where company in(20,22,35) group by ctype,serviceid,statfortime,area
--order by serviceid,statfortime,allfee
)a