zoukankan      html  css  js  c++  java
  • 聚合函数

    总数
    count(*) 表示计算总行数,括号中写星与列名,结果是相同的
    例1:查询学生总数

    1 select count(*) from students;
    count

    最大值

    max(列) 表示求此列的最大值
    例2:查询女生的编号最大值

    1 select max(id) from students where gender=2;
    max

    最小值

    min(列) 表示求此列的最小值
    例3:查询未删除的学生最小编号

    1 select min(id) from students where is_delete=0;
    min

    求和

    sum(列) 表示求此列的和

    1 例4:查询男生的总年龄
    2 select sum(age) from students where gender=1;
    3     – 平均年龄
    4 select sum(age)/count(*) from students where gender=1;
    sum

    平均值

    avg(列) 表示求此列的平均值
    例5:查询未删除女生的编号平均值

    1 select avg(id) from students where is_delete=0 and gender=2;
    avg
  • 相关阅读:
    CSRF攻击原理
    大前端
    尊敬自己,才能拥有改变的力量
    重温尼采语录 序章
    人生的弹性 -- 观《聚宝盆》有感
    求学梦
    爱国情怀
    雾中见我
    找东西
    走在路上的感悟
  • 原文地址:https://www.cnblogs.com/yun---meng/p/13127558.html
Copyright © 2011-2022 走看看