美文网首页
SQL聚合函数

SQL聚合函数

作者: 冷煖自知 | 来源:发表于2020-02-05 10:21 被阅读0次
    count(*)总数
    select count(*) from person;
    select count(*) from person where age=18;
    
    max最大值 min最小值
    select max(age) from person;
    select min(id) from person where age=17;
    
    sum求和 avg平均值(默认4位小数)
    select sum(age) from person where gender=1;
    select avg(age) from person where gender=1;
    select sum(age)/count(*)  from person where gender=1;
    
    round四舍五入
    select round(avg(age),2)  from person where gender=1;
    

    相关文章

      网友评论

          本文标题:SQL聚合函数

          本文链接:https://www.haomeiwen.com/subject/gxbjxhtx.html