MySQL经典练习题(四)
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
欢迎批评指正,提出问题,谢谢!