mysql实现复杂groupby : GROUP_CONCAT
select che,GROUP_CONCAT(concat_ws(':',routeNo,num) ORDER BY num DESC SEPARATOR ',') as gg from (select che,routeNo,count(distinct paicheNo) as num from tableA where carrierType=1 and length(deptName)>1 and paicheCreateTime >= date_sub(now(),interval 4 WEEK) and length(che)>5 and che not like '%汇%' group by che,routeNo order by che,num desc) a group by che limit 5;