zoukankan      html  css  js  c++  java
  • 数据库———聚合函数与分组

    count:统计行数

    select count(*) from student 

    select count(age) from student  /*会不计null值*/

    sum:返回列中值的和,会自动跳过null值(数值+null=null)

    select sum(age) from student

    avg:返回结果集中的所有值的平均值

    select avg(age)from student

    max/min:返回所有值中的最大/小值

    select max(age) from student

    Group by :数据分组查询

    select  age,name,count(*) from student Group by age  /*以年龄段进行分组查询,并且统计每个年龄段有多少人*/

    having:在分组后再次对数据进行过滤

    select  age,name,count(*) from student Group by age having age=21

  • 相关阅读:
    python生成CSV文件并发送邮件
    Live2d Test Env
    Live2d Test Env
    Live2d Test Env
    Live2d Test Env
    Live2d Test Env
    Live2d Test Env
    Live2d Test Env
    Live2d Test Env
    扔鸡蛋
  • 原文地址:https://www.cnblogs.com/JackieADBM/p/5495008.html
Copyright © 2011-2022 走看看