MySQL经典练习题(四)

2021/6/29 2:20:37

本文主要是介绍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



这篇关于MySQL经典练习题(四)的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程