select练习1

时间:2023-03-09 13:24:45
select练习1

1、 查询Student表中的所有记录的Sname、Ssex和Class列。

select t.sname ,t.ssex , t.sclass from student t

select练习1

2、 查询教师所有的单位,即不重复的Depart列。

select distinct depart from teacher

select练习1

3、 查询Student表的所有记录。

select * from student;

select练习1

4、 查询Score表中成绩在60到80之间的所有记录。

select s.* from score s where s.degree>=60 and s.degree<=80;

select s.* from score s where s.degree between 60 and 80;

select练习1

5、 查询Score表中成绩为85,86或88的记录。

select s.* from score s where s.degree=85 or s.degree=86 or s.degree=88;

select练习1

6、 查询Student表中“95031”班或性别为“女”的同学记录。

select t.* from student t where t.sclass=95031 or t.ssex='女';select练习1

7、 以SClass降序查询Student表的所有记录。

select * from student order by sno;

select * from student order by sno desc;

select * from student order by sclass desc;

select练习1

8、 以Cno升序、Degree降序查询Score表的所有记录。

select * from score order by cno, degree desc;

select练习1

9、 查询“95031”班的学生人数。

select count(1) from student where sclass='95031';

select练习1

10、 查询Score表中的最高分的学生学号和课程号。

select max(degree) from score ;

select sno,cno from score where degree = (select max(degree) from score );

select练习1