mysql 区间分组统计

select elt(interval(c.money, 0, 1000, 2000, 3000, 4000, 5000), 'less 1000', '1000to2000', '2000to3000', '3000to4000','4000to5000') as level, count(c.id) as cnt from (select sum(a.money) as money,b.id from 表1 as a,表2 as b where a.uid = b.id group by b.id) as c group by elt(interval(c.money, 0, 1000, 2000, 3000, 4000, 5000), 'less 1000', '1000to2000', '2000to3000', '3000to4000','4000to5000')


--------------

  1. select   
  2. sum(  
  3.          case   
  4.          when examination_score between 90 and 100   
  5.          then 1 else 0   
  6.          end  
  7.        ) as 优秀,  
  8. sum(  
  9.         case   
  10.         when examination_score between 80 and 90   
  11.         then 1 else 0   
  12.        end  
  13.        ) as 良好  
  14. from el_test_info 


  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值