33. 查询成绩比该课程平均成绩低的同学的成绩表. select * from score a where a.degree between 0 and( select avg(degree) from score b where a.cno=b.cno ) 34. 查询所有任课教师的Tname和Depart. select tname,depart from teacher where tno in( select tno from course ) 35 . 查询所有未讲课的教师的Tna
29.查询选修编号为"3-105"课程且成绩至少高于选修编号为"3-245"的同学的Cno.Sno和Degree,并按Degree从高到低次序排序. select tname,prof from teacher where depart = '计算机系' and prof not in ( select prof from teacher where depart = '电子工程系') 30.查询选修编号为"3-105"且成绩高于选修编号为&q
1.先写一个Student类 public class Student { private String name; private int chinese; private int math; private int english; public Student() { super(); } public Student(String name, int chinese, int math, int english) { this.name = name; this.chinese = ch
一.SQL语言查询选修了全部课程的学生的学号和姓名. 两种解决途径: 第一种: 我们可以表示为在SC表中某个学生选修的课程数等于C表中课程总数.相应的SQL语言如下: select S#,SNAME from S where S# in (select S# from SC group by S# --根据Sno分组,统计每个学生选修了几门课程.如果等于C表课程的总数,就是我们要找的S# having count(*) = (select count(*) from C))--统计C表中共有几门
SELECT SUM(CASE WHEN C# ='001' THEN score ELSE 0 END)/SUM(CASE C# WHEN '001' THEN 1 ELSE 0 END) AS 企业管理平均分 ,100 * SUM(CASE WHEN C# = '001' AND score >= 60 THEN 1 ELSE 0 END)/SUM(CASE WHEN C# = '001' THEN 1 ELSE 0 END) AS 企业管理及格百分数 ,SUM(CASE WHEN C# =
传送门:https://www.shiyanlou.com/courses/running 介绍 现需要构建一个简易的成绩管理系统的数据库,来记录几门课程的学生成绩.数据库中有三张表分别用于记录学生信息.课程信息和成绩信息. 数据库表的数据如下: 学生表(student):学生 id .学生姓名和性别 课程表:课程 id 和课程名 成绩表:成绩 id .学生 id .课程 id 和分数 服务器中的 MySQL 还没有启动,请注意 MySQL 的 root 账户默认密码为空. 目标 1.MySQL
select sname from student where not exists (select * from course where not exists (select * from sc where sno =student.sno and cno=course.cno); 最内部的 select * from sc where sno=student.sno and cno = course.cno是查询出所有已经选择过课程的学生及相应课程,select * from cour
查找各个学科的成绩前3名的学生信息Sql,有2种方法,一种是利用sql的row_number() over()函数,另一种是用子查询, 表设计如下 如果不考虑各个学科的成绩有并列的情况的话,有如下两种方法进行查询, 1. ROW_NUMBER() OVER()函数 select * from (select ROW_NUMBER() OVER(partition by CourseName ORDER BY Score desc) AS rownum,* from MyTest) as awhe
相信用过hibernate的兄弟们都会因为多表复杂查询后,为返回的结果如何组装到一个VO中而烦恼不已.我也不停的为此而烦恼,但是在看了hibernate的transform后,感觉这个方法还挺管用的. 例如现在有两张表,一张是user表,放了一些用户的信息,另外一张表是用户发表的帖子,里边有一个user的外键.我们需要查询出来,某个人发布的帖子,sql如下: select u.userName,p.title,p.addTime from user as u,post as p whe
查询所有数据库占用磁盘空间大小的SQL语句: ,),' MB') as data_size, concat(,),'MB') as index_size from information_schema.tables group by TABLE_SCHEMA order by data_length desc; 查询单个库中所有表磁盘占用大小的SQL语句: ,),' MB') as data_size, concat(,),' MB') as index_size from informatio