简介 目录 评价 推荐
  • PENG121 2025-03-10

    -- 聚合函数: 对表中的数据进行统计和计算,一般结合分组(GROUP BY)来使用,用于统计和计算分组数据

    COUNT() 计算查询到的多少条数据

    SUM() 计算查询结果中所有指定字段的和

    AVG() 计算查询结果中所有指定字段的平均值

    MAX() 求查询结果中指定字段的最大值

    MIN() 求查询结果中指定字段的最小值


    select * from student;

    select count(*) from student;

    select count(id) from student;


    select sum(age) from student;

    select avg(age) from student;

    select max(age) from student;

    select min(age) from student;


    --给查询出来的字段起别名  两种写法同效果

    select count(*) as total from student;  

    select count(*) total from student;

    https://img1.sycdn.imooc.com/05bd2f6709ce9ac902540048.jpg

    0赞 · 0采集
数据加载中...
开始学习 免费