2020-11-11

聚合函数:

1.求总和:

- count 格式:count(列名)优化格式:格式1.count( * )格式 2. count(常量)
例子:select count (列名)/count( * )/count(1,2…) from 表名;
- sum 求总和:sum(列名)
例子:select sum(列名) from 表名;
- avg 求平均值函数:avg(列名)
例子:select avg (列名) from 表名;
- min 求最小值:min(列名)
例子:select min (列名) from 表名;
- max 求最大值:max(列名)
例子:select max (列名) from 表名;



group by 分组:

格式: select 分组依据列,其它 from 表名 group by 分组的依据列

进阶:select 分组依据列,其它 from 表名 group by 分组的依据列 having 小组条件

多列分组:group by 分组依据列1,分组依据列n



# 模糊查询: ### 1. 通配符查询:
- _ 代表一个
例子:select * from Table_2 where name like ‘__’;
- % 赖子
例子:select * from Table_2 where name like ‘%白%’;
- [内容a,内容b] 字符集
例子:select * from 表名 where 列名 like ‘[孙,李]%’;
- [^内容a,内容b] 字符集取反
例子:select * from 表名 where 列名 like ‘[^孙,李]%’;

2.范围查询:

- between…and
格式:列名 between最小值and最大值
例子:select * from goods where name like ‘%小米%’ and name like ‘%手机%’ and price between 1399 and 2000;
- …and…
格式:列名>=最小值and<=最大值
例子:select * from goods where name like ‘%小米%’ and name like ‘%手机%’ and price >=1000 and price <= 2000;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值