【聚合函数】

目录

数量 count(*或者0)

 求数量

 求和

select sum(*)from表名

求平均值

最小值

最大值

分组查询 

为字段取别名(as可以省略)

查询daniel老师的上课教室

交叉连接4*3=12条

 内连接

 左连接               

 右连接

 查询Daniel老师的授课表课程名​

子查询in

 子查询not in

 子查询exists

 子查询any

​子查询all 



数量 count(*或者0)

select count()from表名

select count(*)from表名

 求数量

select count(字段名)from表名

 求和

select sum(*)from表名

求平均值

select  avg(字段名)from 表名

最小值

select  min(字段名)from 表名

最大值

select  max(字段名)from 表名

分组查询 

select 字段名, sum(sal), avg(comm), count(comm)from表名 group by 字段名;

select字段名, sum(sal).... from表名 group by 字段名 having 条件;

为字段取别名(as可以省略)

select 字段名 (可写函数)as 字段别名

查询daniel老师的上课教室

交叉连接4*3=12条

select * from 表名1 cross join 表名2

 内连接

select * from 表名1 inner join 表名2 on 表名1.表1字段名 = 表名2.表2字段名;

          左连接               

 select * from 表名1 left join 表名2 on 表名1.表1字段名 = 表名2.表2字段名;

 右连接

select * from 表名1 right join 表名2 on 表名1.表1字段名 = 表名2.表2字段名;

 查询Daniel老师的授课表课程名

子查询in

select * from 表名 where 条件 字段 in (查询语句);

 子查询not in

select * from 表名 where 条件 字段 not in (查询语句);

 子查询exists

select * from 表名 where exists (查询语句);

 子查询any

select * from 表名 where 条件 字段 > any (查询语句);

子查询all 

 select * from 表名 where 条件 字段 > all(查询语句);

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

G-BLUE

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值