DQL聚合运算

-- DQL聚合函数:将一列函数作为一个整体,进行纵向计算
-- select 聚合函数名(列名) from 表;
/*      聚合函数
    * count : 统计数量
        *取值:
            1,主键
            2,*
    * max : 求最大值
    * min : 求最小值
    * sum :求和
    * avg :求平均值
*/
-- 1,统计一共有多少id
select count(AgentID) from agent; -- 列名字不能为空
select count(*) from agent; -- 查询所有
-- 2,查询电话最大
select max(Phone) from agent; -- null值不参与聚合函数的运算
-- 3,查询电话最小
select min(Phone) from agent;
-- 4,查询电话总分
select sum(Phone) from agent;
-- 5,查询电话平均分
select avg(Phone) from agent;

 

 

posted @ 2022-11-10 22:28  YE-  阅读(21)  评论(0编辑  收藏  举报