时间:2021-07-01 10:21:17 帮助过:8人阅读
1、查询成绩比该课程平均成绩低的同学的成绩表
SELECT *
FROM score AS a
WHERE degree < (SELECT AVG(degree) FROM score AS b WHERE a.cno = b.cno)
2、查询所有任课教师的Tname和Depart.
select tname,depart
from teacher t,course c
where t.tno = c.tno
3、查询所有未讲课的教师的Tname和Depart
select Tname,Depart
from Teacher
where Tname not in (select Tname from Teacher,Course,Score where Teacher.Tno=Course.Tno and Course.Cno=Score.Cno)
4、查询至少有2名男生的班号。
select class
from student
where ssex =‘男‘
group by class
having count(sno)>=2
5、查询Student表中不姓“王”的同学记录。
select *
from student
where sname not like ‘王%‘
6、查询Student表中最大和最小的Sbirthday日期值。
select MAX(Sbirthday) as min_sbirthday,MIN(Sbirthday) as max_sbirthday
from student
MySQL经典练习题(四)
标签:sql 练习 info art 成绩 记录 core rom like