• 模糊查询和聚合函数


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

    通配符
    他可以代替一个或多个真正的字符,与“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平均分
    --查询成绩表中的平均分、最大值和最小值
    select AVG(StudentResult) as 平均分,MAX(StudentResult) as 最大值,MIN(StudentResult) as 最小值
    from Result
    where StudentResult >= 60

    --求和
    select COUNT(*) from Result
    where StudentResult >= 60

    --找到学员S1101004的成绩
    select * from Student
    select * from Result where StudentNo = 'S1101004'

     

     

     

     

     

     

     

     

     

  • 相关阅读:
    C/C++ 读文件
    算法和数据结构 图表示
    protobuf
    C/C++ jsoncpp
    C/C++ C++11作用域枚举
    腾讯云云函数快速入门实践
    Serverless 与 Flask 框架结合进行 Blog 开发
    从企业微信机器人到小爱同学,用 Serverless 实现生活智能化!
    基于 Serverless 与 Websocket 的聊天工具实现
    云函数 SCF 与对象存储实现 WordCount 算法
  • 原文地址:https://www.cnblogs.com/SFHa/p/8258156.html
Copyright © 2020-2023  润新知