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;

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM