当前位置:Gxlcms > 数据库问题 > sql server 模糊查询和聚合函数

sql server 模糊查询和聚合函数

时间:2021-07-01 10:21:17 帮助过:42人阅读


              用于在WHERE子句中搜索列中的指定模式,只与字符型数据联合使用
                       示例:select StudentName,Address
                                  from Student
                                  where Address like ‘%山东%‘
                                              查询住址包含山东的学生信息

 

5.模糊查询——is null
                        判断指定变量是否为空
                                       示例:select StudentName,Email
                                                  from Student
                                                  where Email is null or Email=‘ ‘
                                                                查询邮件为空的学生信息

 

6.模糊查询——between
                     查询某一列中内容在特定范围内的记录
                               示例:select Score,StudentName
                                         from Student
                                         where Score between 60 and 80
                                                         查询成绩在60到80分的学生信息

 

7.模糊查询——in
                    查询某一列中内容与所列出的内容列表匹配的记录,严格限制
                              示例:select StudentNmae,Address
                                        from Student
                                        where Address in (‘山西‘,‘北京‘)
                                                     查询住址为山西,北京的学生信息

 

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

 

9.聚合函数
                SUM():求和
                             示例:select sum(Score)
                                       from Score
                                       where StudenNo=‘202026‘
                                                 查询学号为202026的学生成绩总和

                   AVG():求平均数
                                示例:select avg(Score)
                                           from Score
                                                    查询所有学生的平均成绩

                  MAX():求最大值
                                 示例:select max(Score)
                                           from Score
                                            where SubjectName=‘java‘
                                                         查询参加Java考试的学生的最高分

                    MIN():求最小值
                                  示例:select min(Score)
                                              select Score
                                               where SubjectName=‘java‘
                                                            查询参加java考试的学生的最低分

                   COUNT():计数
                                 示例:select count(*)
                                           from Score
                                           where SubjectName=‘java‘
                                                         查询参加java考试的人数

 

10.is null 和 ‘ ’的区别
                  is null:没有值
                ‘ ’:有一个值,为空

 

sql server 模糊查询和聚合函数

标签:联合   山西   HERE   count   sql   严格   min()   使用   系统   

人气教程排行