模糊查询和聚合函数

模糊查询和聚合函数

模糊查询

在大批量的数据中进行,模糊条件的查找,只知道部分条件(单个字符,单个数字)

不明确的、大概的

通配符

他可以代替一个或多个真正的字符,与“like”一起用

-                 一个字符

%                  任意长度的字符

[]                   括号范围中的

[^]                 不在括号范围中的一个字符

select * from Student where StudentName like '冯_'

select * from Student where Address like '%舍%'

select * from Student where StudentNo like 'S110100[1-9]'

select * from Student where StudentNo like 'S110100[^1-2]'

查询空

select * from Student where Email is null

 

select * from Student where Email = ''

between关键字查询区间的(数值只能从小到大)

select * from Result where StudentResult Between 90 and 100

in关键字(值必须准确)

select StudentName as 姓名,Address as 地址

from Student

where Address in('天津市河西区','河南省南阳市','学生宿舍')

 

 

聚合函数:对一组值进行计算,并返回计算后的值,具有统计数据的作用

--求和SUM()

select SUM(StudentResult) AS 总成绩 from Result

--AVG平均分

原文地址:https://www.cnblogs.com/QiliPING9/p/8259472.html