zoukankan      html  css  js  c++  java
  • 连接查询和分组查询

    1.使用GROUP   BY进行分组查询

         语法

               select  studentid   avg(score)  from   student   group  by  studentid

               结果就会吧学生ID个样的分到一组,计算他们的平均成绩

    2.多列分组查询

       例

           统计每个男生女生的人数,则理论上先把每个学期分开,在针对每个学期把男女生人数各自统计

             select   count(*)   sgrande     ssex     from   student   

             group   by   sgrande,ssex

             order  by    sgrade

    3.使用having 子句进行分组查询

        (1)    select   count(*),sgrande    from   stufent   group by  sgrande

                 having   count(*)>15

                 查询年级总人数超过15人的年级

     多连接分类

           内连接查询

                       内连接查询是最典型的,最常用的链接查询

                   语法

                      在where子句中指定连接条件

                       select   studentname ,score.courseid,score.score

                      where.  stident.scode =score.studentid

                在from子句中

                     select   student.name,score.studentid,score.score.  from.  student

                    inner. join. score. on(student.scode=score.studentid)

         外连接查询

                      外连接查询是至少返回一个表中的所有记录,根据匹配条件有选择性的

                      返回另一张表的记录

              左外连接查询

                  左外连接查询的结果集包括LEFT.  JOIN子句中指定的坐标的所有行,而不仅仅是连接列所匹配的行,若左表中没有匹配上,则在相关联的结果集行中右表的所有选择列均为空值

             语法

                 SELECT. s.sname,c.couresid,c.score

                 from.  student

                 left.  outer.   join.   score.   on. student.scode. =c.studentid

  • 相关阅读:
    二分查找和线性查找(二)
    自定义数组java(一)
    MATLAB中load和imread的读取方式区别
    图像Demosaic算法及其matlab实现
    Matlab GUI学习总结
    matlab gui matlab gui 鼠标点击显示图像颜色值
    【图像处理】RGB Bayer Color分析
    MATLAB图像处理_Bayer图像处理 & RGB Bayer Color分析
    IPC图像处理项目流程图
    matlab图像处理程序大集合
  • 原文地址:https://www.cnblogs.com/wk7799666/p/7745864.html
Copyright © 2011-2022 走看看