1、以班号和年龄从大到小的顺序查询Student表中的全部记录。
select *
from student
order by class desc,sbirthday ;
2、查询“男”教师及其所上的课程。
-- 方法一
select tname,t.TNO,t.tsex
from teacher t,course c
where t.TSEX='男'and t.tno =c.tno
-- 方法二
select tname,t.TNO,t.tsex
from teacher t inner join course c
on t.tsex ='男'and t.tno = c.tno
3、查询最高分同学的Sno、Cno和Degree列。
select sno,cno,degree
from score
where degree = (select max(degree) from score)
4、查询和“李云”同性别的所有同学的Sname.
select sname
from student
where ssex = (select ssex from student where sname='李云')
5、查询和“李云”同性别并同班的同学Sname.
select sname
from student
where ssex = (select ssex from student where sname='李云') and class =(select class from student where sname='李云')
6、查询所有选修“计算机导论”课程的“男”同学的成绩表
select *
from score
where sno in (select sno from student where ssex='男' and sno in(
select sno from score where sno in (select sno from score where cno = (select cno from course where cname='计算机导论'))))
order by sno