学生选课数据库SQL语句练习题

1、
select Sname , Ssex  ,Class from t_hq_student;

2、
select distinct Depart from t_hq_teacher;

3、
select * from  t_hq_student;

4、
select * from t_hq_Score where Degree between 60 and 80;

5、
select * from t_hq_Score where Degree in('85','86','88');

6、
select * from  t_hq_student where class = '95031' and Ssex = '女';

7、

select * from t_hq_Student order by class desc;

8、
select cno as 课程号,degree as 成绩 from t_Hq_Score order by Cno asc,degree desc;

9、

select class,count(1)as 数量 from t_hq_Student group by class;

10、select * from t_hq_Score where degree >= all (select degree from  t_hq_Score);


11、
select cno,count(1)as 数量 , avg(degree) as 平均值  from t_hq_Score  group by cno;


12、
select cno,count(1)as 数量,avg(degree) as 平均值 from t_hq_Score  where cno like '3%'group by cno having count(1) >=5;

13、
select Sno from t_hq_Score where degree between 70 and 90;

14、查询所有学生的Sname、Cno和Degree列。

Select s.sname,c.cno,c.degree from  t_hq_student s ,t_hq_score c where s.sno=c.sno;

15、查询所有学生的Sno、Cname和Degree列。

select c.sno,s.cname,c.degree from  t_hq_course s,t_hq_score c where c.cno = s.cno ;

17、
select avg(degree) as 平均值 from t_Hq_Score where sno in (select sno from t_Hq_student where class = 95033 );

19、
select * from t_hq_Score where Cno= '3-105' and degree > (select degree from  t_hq_Score where  Cno= '3-105' and Sno ='109');


21、
 select * from t_hq_Score where degree > (select degree from t_hq_Score where sno = '109'and cno = '3-105' );

23、查询“张旭“教师任课的学生成绩。
select * from t_hq_Score where cno in(select cno from t_hq_course where tno in(select tno from t_hq_teacher where Tname = '张旭') );

原文地址:https://www.cnblogs.com/chenning/p/4916546.html