多表查询-子查询(一)

第1关:子查询

任务描述

本关任务:求年龄大于'刘东明' 的所有学生的姓名与出生日期。

编程要求

在右侧编辑器补充代码,求年龄大于'刘东明' 的所有学生的姓名与出生日期。 --学生表student

 use teachingdb;
 /****请在此编写代码,操作完毕之后点击评测******/
 
 /**********Begin**********/
  select sname,birthday from student where birthday < (select birthday from student where sname = "刘东明");
  
 /**********End**********/


第2关:子查询-练习 

任务描述

本关任务:求未选修任何课程的学生的学号和姓名。

编程要求

根据提示,在右侧编辑器补充代码,求未选修任何课程的学生的学号和姓名。 --学生表student --成绩表score

 use teachingdb;
 /****请在此编写代码,操作完毕之后点击评测******/
 
 /**********Begin**********/
  select sno,sname from student
  where sno not in(select sno from score);
  
 /**********End**********/


第3关:子查询-练习一 

任务描述

本关任务:求比数学系中全体学生年龄大的学生的姓名和系

编程要求

根据提示,在右侧编辑器补充代码,求比数学系中全体学生年龄大的学生的姓名和系。 --学生表student

 use teachingdb;
 /****请在此编写代码,操作完毕之后点击评测******/
 
 /**********Begin**********/
  select sname,sdept,birthday from student
  where birthday < all(select birthday from student where sdept = '数学');
  
 /**********End**********/


第4关:子查询-练习二 

任务描述

本关任务:求选修了004课程的学生的姓名和系。

编程要求

根据提示,在右侧编辑器补充代码,求选修了004课程的学生的姓名和系。 --学生表student --成绩表score

 use teachingdb;
 /****请在此编写代码,操作完毕之后点击评测******/
 
 /**********Begin**********/
  select sname,sdept from student
  where sno in (select sno from score where cno = '004');

 /**********End**********/


第5关:子查询-练习三

任务描述

本关任务:求选修了'刘东明' 同学选修的全部课程的学生的学号。

相关知识

见上一关

编程要求

在右侧窗口补充代码,求选修了'刘东明' 同学选修的全部课程的学生的学号。 --学生表student --成绩表score

 use teachingdb;
 /****请在此编写代码,操作完毕之后点击评测******/
 
 /**********Begin**********/
 select sno from score where cno in(select cno from score,student where score.sno = student.sno and sname = '刘东明') and score.sno!= (select sno from student where sname = '刘东明') group by sno having count(cno)>=2 ;
  
 /**********End**********/


第6关:子查询-练习四

任务描述

本关任务:求选修了全部课程的学生的学号。

相关知识

见上一关

编程要求

根据提示,在右侧编辑器补充代码, 求选修了全部课程的学生的学号。 --学生表student --成绩表score --课程表course

 use teachingdb;
 /****请在此编写代码,操作完毕之后点击评测******/
 
 /**********Begin**********/
/*  select sno from student where not exists(select * from course where not exists(select * from score where score.sno = student.sno and score.cno = course.cno));*/
select sno from score group by sno having count(*)=
(select count(*) from course);
  
 /**********End**********/


  • 7
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值