zoukankan      html  css  js  c++  java
  • mysql,分组后,再次进行过滤

    查出平均分大于80以上的班级

    select class_id, avg(score) from students group by class_id having avg(score)>80;   --对分组之后进行过滤使用having,不能使用where

    查出班级中男生平均分大于80分以上的班级

    select class_id,avg(score) from students where gener = 'M' group by classe_id having avg(score)>80;--先执行where语句,筛选出男生,再分组,再having

  • 相关阅读:
    Git
    Spring
    Linux
    Linux
    Linux
    Linux
    Linux
    Linux
    Linux
    Linux
  • 原文地址:https://www.cnblogs.com/tarzen213/p/11833110.html
Copyright © 2011-2022 走看看