云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > sql练习题及答案

sql练习题及答案

  • 62 次阅读
  • 3 次下载
  • 2025/5/4 3:52:49

where sno notin(select sno from cs)

(35) 查询每个学生及其选修课程的情况。

select cs.sno,course.*from cs,course where cs.cno=course.cno

(36) 查询选修2号课程且成绩在90分以上的所有学生的学号、姓名

select sno,sname from student where sno=(select sno from cs where cno=2 and cj>90)

(37) 查询每个学生的学号、姓名、选修的课程名及成绩。

select student.sno,sname,course.course,cs.cj from student,course,cs where student.sno=cs.sno and cs.cno=course.cno

(38) 查询与“刘晨”在同一个系学习的学生(分别用嵌套查询和连接查询)

----嵌套查询 select*from student where dept in (select dept from student where sname='刘晨')

----连接查询 select stu1.*from student as stu1,student as stu2 where stu1.dept=stu2.dept and stu2.sname='刘晨' ----exists查询 select*from student s1 whereexists( select*from student s2 where s1.dept=s2.dept and s2.sname='刘晨' )

(39) 查询选修了课程名为“信息系统”的学生学号和姓名

select sno,sname from student where sno in (select sno from cs where cno in(select cno from course where cname='信息系统'))

(40) 查询其他系中比信息系任意一个(其中某一个)学生年龄小的学生姓名和年龄

select sname,age from student where age

(41) 查询其他系中比信息系所有学生年龄都小的学生姓名及年龄。分别用

ALL谓词和集函数

----用ALL select sname,age from student where age

(42) 查询所有选修了1号课程的学生姓名。(分别用嵌套查询和连查询)

----嵌套查询 select sname from student where sno in (select sno from cs where cno=1) ----连接查询 select sname from student,cs where student.sno=cs.sno and cs.cno=1

(43) 查询没有选修1号课程的学生姓名。

select sname from student where sno in (select sno from cs where cno!=1)

(44) 查询选修了全部课程的学生姓名。

select sname from student wherenotexists (select*from course wherenotexists (select*from cs where cs.sno=student.sno and cs.cno=course.cno))

(45) 查询至少选修了学生95002选修的全部课程的学生号码。

selectdistinct sno from sc scx wherenotexists (select*from cs scy where scy.sno='95002'andnotexists (select*from sc scz where scz.sno=scx.sno and scz.cno=scy.cno))

(46) 查询计算机科学系的学生及年龄不大于19岁的学生的信息。

select*from student where dept='计算机科学系'or age<19

(47) 查询选修了课程1或者选修了课程2的学生的信息。

搜索更多关于: sql练习题及答案 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

where sno notin(select sno from cs) (35) 查询每个学生及其选修课程的情况。 select cs.sno,course.*from cs,course where cs.cno=course.cno (36) 查询选修2号课程且成绩在90分以上的所有学生的学号、姓名 select sno,sname from student where sno=(select sno from cs where cno=2 and cj>90) (37) 查询每个学生的学号、姓名、选修的课程名及成绩。 select student.sno,sname,course.course,cs.cj from student,course,cs where

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com