练习题

1.select Sname,Ssex,Class from student
2.select distinct depart from teacher
3.select * from student
4.select * from score where degree between 60 and 80
5.select * from score where degree in(85,86,88)
6.select * from student where class='95031' or Ssex='女'
7.select * from student order by class desc
8.select * from score order by cno,degree desc
9.select count(*) from student where class='95031'
10. select sno,cno from score where degree =(select max(degree) from score)
11.select cno,avg(degree) from score group by cno
12.select avg(degree) from score where cno like'3%' group by cno having count(*)>=5
select avg(degree) from score group by cno having count(*)>=5 and cno like'3%'

13.select sno from score where degree>70 and degree<90

14.select sname,cno,degree from score join student on score.sno = student.sno

15.select sno,cname,degree from score join course on score.cno=course.cno

16.select sname,cname,degree from score join student on student.sno=score.sno join course on score.cno = course.cno

select sname,cname,degree from score,student,course where student.sno=score.sno and score.cno = course.cno

17.select avg(degree) from score where sno in(select sno from student where class='95033')

18.select sno,cno,rank from score,grade where degree between low and upp

19. select * from score where cno='3-105' and degree>(select degree from score where sno='109' and cno='3-105')

select * from score where cno='3-105' and degree>(select max(degree) from score where sno='109')

20. select * from score a where sno in (select sno from score group by sno having count(*)>1) and degree <(select max(degree) from score b where b.cno=a.cno)

21.select * from score where degree>(select degree from score where sno='109' and cno='3-105')

22.select * from student where YEAR(sbirthday) = (select YEAR(sbirthday) from student where sno='108')

23. select * from score where cno in(select cno from course where tno in(select tno from teacher where tname='张旭'))

24.select tname from teacher where tno in(select tno from course where cno in(select cno from score group by cno having count(*)>=5))

25.select * from student where class in('95033','95031')

26.select distinct cno from score where degree>85

27.select * from score where cno in(select cno from course where tno in(select tno from teacher where depart='计算机系'))

28.select tname,prof from teacher where depart='计算机系' and prof not in(select prof from teacher where depart='电子工程系')union
select tname,prof from teacher where depart='电子工程系' and prof not in(select prof from teacher where depart='计算机系')

select tname,prof from teacher a where prof not in(select prof from teacher b where b.depart != a.depart)

29.select * from score where cno='3-105' and degree>any(select degree from score where cno='3-245')

原文地址:https://www.cnblogs.com/weiwenxin01/p/5752243.html