1. 还原数据库stuinfo071128为考生数据库,名字为“学号最后两位 姓名”
2. 查询考生数据库t_score表的s_number,score两列,并在返回的结果中将每个学生的成绩增加5分、
Select S_number,score
from [26林旋波].[dbo].[t_score]
Update [26林旋波].[dbo].[t_score]
set score=score+5
3. 写出在考生数据库t_score表中获得成绩介于60到80分(包含边界值)的学生学号的sql语句
select * from [26林旋波].[dbo].[t_score]
where score between 60 and 80
4. 查询考生数据库t_student表中 学号第一个字符是0,第三个字符是0,最后一个字符是1到3的所有学生资料(模糊查询)
Select * from [26林旋波].[dbo].[t_student]
where S_number like '0%0%[1-3]'
5. 使用统计函数统计考生数据库,t_score表中学生成绩在80分以上的人数(去除重复值)
select t_score.score,t_score.c_number ,count(c_number)as 学生人数
from [26林旋波].[dbo].[t_score]
where score>'80'
group by t_score.score,t_score.c_number
order by 学生人数
6. 以t_student为基表,创建一个含有所有女团员详细信息的视图v_4
Create view v_4
As
Select * from [26林旋波].[dbo].[t_student]
Where t_student.sex='女' and t_student.polity='团员'
7. 查询所有男学生的姓名、出生日期、年龄(使用聚合函数完成)
Select s_name,birthday ,count(*) as 学生人数
from [26林旋波].[dbo].[t_student]
where sex='男'
group by s_name,birthday
8. 在考生数据库中查询所有姓李的男学生的姓名、性别、选修课程名称和成绩
Select t_student.s_name 姓名, t_student.sex 性别,
t_course.c_name 课程名称,t_score.score 成绩
from [26林旋波].[dbo].[t_student],[26林旋波].[dbo].[t_score],
[26林旋波].[dbo].t_course
Where t_student.s_number=t_score.s_number
and t_score.c_number=t_course.c_number and s_name like '李%' and sex='男'
