上章节补充
模糊查询:
like where name like‘张%’
% (零个或多个字符)
_ (任意单个字符)
转义符 like '%50<escape char>%%' |
like '%50p%%' escape'p' |
like '%50[%%' | 查找 %50 而不是50
处理控制数据 is null (not null)
where 列名 is null
where 列名 is not null
排序操作 order by 结果以什么顺序显示
【 默认是升序排列 ASC 降序排序为 DESC
where order by age ASC
where order by age DESC
where order by age ASC, name DESC 年龄相同时,安名字降序排列。
【 聚合函数 】
count : 返回结果行的数目
sum : 返回值总和
max : 最大值
min :最小值
avg :【count】 select count (计数规则) as 存入列名 from 表名
计数规则 * 、all、*
select count (*) as 总行数 from stu -----
【 包含 NULL 】
select count (distinct name)——————
【 不包含NULL 没计数规则时默认all】
select count (distinct name)——————
【 所有 非NULL,排重复,】
【 sum 】 select sum(计数规则) 存入列名 from 表名
【 不能使用 * 通配符 】
平均值规范 all 、 distinct
select sum (all s_age)from stu【 自动过滤为空的数据】
【 max 】 select max(最大值规范)from 表名
【 min 】 select max (最小值规范) from 表名
【 数据分组 】
【 group 】
select 列A ,聚合函数(规范) from 表名
where 过滤条件
group分组
## 先将表数据加载到内村中,进行过滤,然后进行group分组、显示列A ,聚合函数表达值