当前位置:   article > 正文

mysql 中根据某个字段分组统计 如何优化_mysql 提升分组统计性能

mysql 提升分组统计性能

最近项目中经常遇到根据某个字段分组统计,所以总结一下,我遇到这种问题的思路
#用到临时表
select stu.name,sta.grade,count() from student as stu inner join statistics as sta USING(uid) where sta.grade>90 group by stu.uid
#用到索引
select stu.name,c.grade,c.num from student as stu inner join (select uid,
count(
) as num,grade from statistics where statistics.grade>90 group by uid ) as c USING(uid)

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/230782
推荐阅读
相关标签
  

闽ICP备14008679号