use stuinfo
--查询t_score表中没有选修课程号是5和7的学生信息。
select *
from t_score
where C_number like '[^5,7]%'
--查询t_course表学时在70到80之间(包含70、80)的课程信息。
select *
from t_course
where Hours between 70and 80
--在t_student表中查询姓‘李’的学生的姓名、地址及电话。
select S_name,Address,Phone
from t_student
where S_name like'李%'
--查询t_course表学时是72且学分是6的课程信息。
select *
from t_course
where Hours=72 and Credit=6
--在t_student表中查询所有男学生的姓名、出生年月和年龄
select S_name,Birthday,YEAR(GETDATE())-YEAR(Birthday) as 年龄
from t_student
--在t_student表中查询所有年龄大于35岁的女学生的姓名和年龄。
select YEAR(GETDATE())-YEAR(Birthday) as 年龄,S_name
from t_student
where YEAR(GETDATE())-YEAR(Birthday)>35 and Sex='女'
--查询各年份出生的学生人数。
select YEAR(Birthday) as 年份,count(*) as 学生人数
from t_student
group by YEAR(Birthday)
--在t_score表中查询每位同学的平均分,并按平均分从高到低排列。
select S_number,AVG(Score) as avg
from t_score
group by S_number
order by AVG(Score)
--在t_score表中查询获得课程平均分超过80分的课程信息(显示课程号、课程平均分)。
use stuinfo--查询t_score表中没有选修课程号是5和7的学生信息。select * from t_scorewhere C_number like '[^5,7]%' --查询t_course表学时在70到80之间(包含70、80)的课程信息。select * from t_coursewhere Hours between 70and 80--在t_student表中查询姓‘李’的学生的姓名、地址及电话。select S_name,Address,Phone.