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'

  • 相关阅读:
    50 个 jQuery 插件可将你的网站带到另外一个高度
    查看占用IO的进程
    google全球地址
    php http请求封装
    如何促使团队紧密协作
    pureftpd.passwd解析
    goaccess生成nginx每日访问纪录
    bootstrap的一些资源
    php write_ini_file
    mysql查询区分大小写
  • 原文地址:https://www.cnblogs.com/dnf1612/p/6179857.html
Copyright © 2011-2022 走看看