zoukankan      html  css  js  c++  java
  • 模糊查询和聚合函数

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

    通配符
    他可以代替一个或多个真正的字符,与“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'

     

     

     

     

     

     

     

     

     

  • 相关阅读:
    webpack 入门
    javascript 函数重载另一种实现办法
    5个python爬虫教材,让小白也有爬虫可写,含视频教程!
    简书模拟登陆缺陷!!!
    Python操作Mongodb
    【爬虫系列之一】爬虫开发环境的搭建
    CentOS7.4,anaconda3,python3.6,tensorflow环境下gdal的编译和问题解决
    返回Json格式结果
    json扩展
    EF中使用SQL语句或存储过程
  • 原文地址:https://www.cnblogs.com/SFHa/p/8258156.html
Copyright © 2011-2022 走看看