【上机作业】【SQL】2010.4.17 数据查询的练习
查询 SQL Server 课程分布在 70~90之间的学生所在专业
use students
go
select class
from stu
where stuid in(select stuid
from scores
where couid=’B002′ and score between 70 and 90
)
查询每个班级的学生人数
use students
go
select class,count(*) as 人数
from stu
group by class
查询课程名称包含”计算机”3个字的课程
use students
go
select *
from course
where couname like ‘%计算机%’
查询每个学期开设课程数目大于2的学期
use students
go
select count(*)
from scores
group by term
having count(*)>2
查询”英语”成绩在前三名的学生信息 ,注意分数相等的情况
use students
go
select *
from stu
where
stuid in(
select top 3 with ties stuid
from scores
where couid=’A001′
order by score desc)