ORACLE 中聚合函数使用

–创建表
–创建表且指定表空间
create table student(
id varchar2(20) primary key,
name varchar2(50) not null,
subject varchar2(50) not null,
score number(4,1) not null,
class varchar2(1) not null
) tablespace tablespace01;

1,count():统计总数, sum(字段) : 汇总 字段的值, min(字段) : 字段的中最小值, max(字段) : 字段中最大值
Median(字段) :中位数 ,例如 字段 age 的值 分别为 10 ,20 ,32, 40 ,50 , select Median(age) from 表名; 结果: 32
2 , count(1) ,count(字段) ,count(distinct 字段)
count(1) :统计总条数
count(字段) : 当字段的值 为空 时 ,则该条记录不计入 总条数,例如 select count(*) from 表名; 总条数 为 5,其中 字段 age 中存在一条字段 为空的,则 select count(avg) from 表名 ; 总条数为 4
count(distinct 字段) 相当于 例如 student 表中 有 100 条学生记录 , 存在 3个班级中 (class) ,
select count(distinct class) from student; 结果 : 3
分组函数 : group by
where ,having 过滤条件的不同
where 后紧跟的条件 对全表数据进行 过滤, 在数据分组前
having 为 对分组( group by ) 后的 结果集上加条件过滤

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值