1、查询成绩比该课程平均成绩低的同学的成绩表

SELECT *

FROM score AS a

WHERE degree < (SELECT AVG(degree) FROM score AS b WHERE a.cno = b.cno)

MySQL经典练习题(四)_数据库

2、查询所有任课教师的Tname和Depart.

select tname,depart

from teacher t,course c

where t.tno = c.tno

MySQL经典练习题(四)_数据库_02

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)

MySQL经典练习题(四)_数据库_03

4、查询至少有2名男生的班号。

select class

from student

where ssex ='男'

group by class

having count(sno)>=2

MySQL经典练习题(四)_数据库_04

5、查询Student表中不姓“王”的同学记录。

select *

from student

where sname not like '王%'

MySQL经典练习题(四)_数据库_05

6、查询Student表中最大和最小的Sbirthday日期值。

select MAX(Sbirthday) as min_sbirthday,MIN(Sbirthday) as max_sbirthday

from student

MySQL经典练习题(四)_数据库_06