zoukankan      html  css  js  c++  java
  • select 练习2

    group by :select 分组字段,聚合函数 from 表名 where  条件 group by 分组字段 having 过滤条件

    select cno,avg(degree) from score group by cno

    12、查询Score表中至少有5名学生选修的并以3开头的课程的平均分数。

    having是跟在 group by之后的筛选条件  like''是模糊查询 ''中的%是任意字符数的通配符,-是单个字符数的通配符

    select cno,avg(degree) from score  group by cno having cno like'3%'and count(1)>=5

    13、查询分数大于70,小于90Sno列。

    between 较小值 and 较大值

    select sno from score where degree between 70 and 90

    15、查询所有学生的SnoCnameDegree列。

    join on 多表之间的关联关系

    select s.sno,c.cname , s.degree from score s join course c on s.cno=c.cno

    16、询所有学生的SnameCnameDegree列。

    select s.sname,c.cname, e.degree  from student s,score e, course c  where s.sno = e.sno and e.cno = c.cno

    select s.sname,c.cname, e.degree  from student s join score e on s.sno = e.sno  join course c on e.cno =c.cno

    17、 查询“95033”班学生的平均分。

    select avg(degree) from score e join student s on e.sno = s.sno where sclass='95033'

  • 相关阅读:
    Linux学习之路——ls命令及文件权限
    解析规范格式的日志文件至List中
    Flask
    GIT和github
    常见的面试题
    python—面向对象的封装
    作业—数据类型8.20
    练习—8.17 while循环
    s7day2
    oracle 开窗分析函数和树形结构
  • 原文地址:https://www.cnblogs.com/dnf1612/p/6179857.html
Copyright © 2011-2022 走看看