SQL-SERVER查询练习习题.docVIP

  • 3
  • 0
  • 约7.05千字
  • 约 10页
  • 2024-03-16 发布于江苏
  • 举报

SQL-SERVER查询练习习题

设教学数据库Education有三个关系:

学生关系s(student_id,student_name,birthday,sex,major);

学习关系sc(student_id,course_id,score);

课程关系course(course_id,course_name,term,period,credit)

查询问题:

单表查询

1:查所有年龄在20岁以下的学生姓名及年龄。

selectstudent_name,year(getdate())-year(birthday)as年龄

froms

whereyear(getdate())-year(birthday)30

2:查考试成绩有不及格的学生的学号

selectdistinctstudent_id

fromsc

wherescore60

3:查所年龄在20至23岁之间的学生姓名、系别及年龄。

selectstudent_name,major,year(getdate())-year(birthday)as年龄

froms

whereyear(getdate())-year(birthday)between20and24

4:查舞蹈编导、英语、通信技术专业的学生姓名、性别。

selectstudent_name,se

文档评论(0)

1亿VIP精品文档

相关文档