Orcle数据库查询练习复习:二
一、题目
1.找出所有成绩均低于80的学生姓名
select sname from student where sid in(
select sid from mark group by sid having max(cmark)<80) select sname from student where sid in(
select sid from mark where sid not in(
select sid from mark where cmark>=80))
2.找出和张三同学所选课程完全相同的学生姓名
Step1:select sid from student where sname='张三'
step2:select cid from mark where sid=(step1)
step3:select sid from mark where cid not in (step2)
step4:select sid from mark where sid not in(step3)group by sid having count(*)=(select count(*)from mark where sid=(step1))
3.显示张三同学的数学和英语成绩,要求显示姓名、数学成绩、英语成绩
select sname ,(
select cmark from mark where sid=(select sid from student where sname='张三')
and
cid=(select cid from course where cname='数学')
) 数学成绩,
(
select cmark from mark where sid=(select sid from student where sname='张三')
and
cid=(select cid from course where cname='英语')
) 英语成绩 from studen
至少选修了学生10002选修的全部课程的学生学号
m studenm nt s leftjoin mark m on s.sid=m.sid where cmark<60
5.查询出所有存在不及格课程的学生的姓名
select sname from studenm nt s left join mark m on s.sid=m.sid where cmark<60
6.至少选修了学生10002选修的全部课程的学生学号
select sid from mark sc1 where not exists(
select * from mark sc2 where sid=10002 and not exists
(select *from mark where sid=sc1.sid and cid=sc2.cid
)
) and sid !=10002 group by sid
7.至少选修了学生张三选修的全部课程的学生姓名
select sid from mark sc1 where not exists(
select * from mark sc2 where sid=(select sid from student where sname='张三') and not exists
(select *from mark where sid=sc1.sid and cid=sc2.cid
)
) and sid !=10002 group by sid
Orcle数据库查询练习复习:二的更多相关文章
- Orcle数据库查询练习复习:一
一.创建数据库和表 drop table student; create table student ( sid int, sname ), sage int, ssex ), snativeplac ...
- Orcle数据库查询练习复习:四
一.题目 1.找出张三的最高分和最低分以及对应的课程名 select * from course c,mark m where c.cid=m.cid and sid =(select sid fro ...
- Orcle数据库查询练习复习:三
一.题目 1.与“张三”同乡的男生姓名 select * from student where snativeplace=(select snativeplace from student where ...
- mongodb基础系列——数据库查询数据返回前台JSP(二)
上篇博客论述了,数据库查询数据返回前台JSP.博客中主要使用Ajax调用来显示JSON串,来获取其中某一个字段,赋给界面中的某一个控件. 那这篇博客中,我们讲解,把后台List传递JSP展示. Lis ...
- 工程师技术(二):postfix基础邮件服务、postfix空客户端邮件服务、搭建mariadb数据库系统、配置一个数据库、使用数据库查询
一.postfix基础邮件服务 目标: 本例要求在虚拟机server0上配置 postfix 基础服务,具体要求如下: 1> 监听本机的所有接口 2> 将邮件域和邮件服务主机名都改为 ...
- Spring Security教程(二):自定义数据库查询
Spring Security教程(二):自定义数据库查询 Spring Security自带的默认数据库存储用户和权限的数据,但是Spring Security默认提供的表结构太过简单了,其实就 ...
- (十二)数据库查询处理之Query Execution(1)
(十二)数据库查询处理之Query Execution(1) 1. 写在前面 这一大部分就是为了Lab3做准备的 每一个query plan都要实现一个next函数和一个init函数 对于next函数 ...
- shiro(二)自定义realm,模拟数据库查询验证
自定义一个realm类,实现realm接口 package com; import org.apache.shiro.authc.*; import org.apache.shiro.realm.Re ...
- 【数据库】SQL经典面试题 - 数据库查询 - 子查询应用二
上节课我们通过子查询,完成了查询的最高分学生的需求,今天我们来学习子查询的分类,以及通过子查询来完成工作中经常遇到一些个性化需求. 子查询概念: 一个SELECT语句嵌套在另一个SELECT语句中,子 ...
随机推荐
- JAVA多线程学习--哲学家就餐问题
哲学家就餐问题是1965年由Dijkstra提出的一种线程同步的问题. 问题描述:一圆桌前坐着5位哲学家,两个人中间有一只筷子,桌子中央有面条.哲学家思考问题,当饿了的时候拿起左右两只筷子吃饭,必须拿 ...
- jQuery对Select操作大集合
介绍了jQuery对Select的操作进行了详细的汇总. 1.jQuery添加/删除Select的Option项: 2.$("#select_id").append("& ...
- GridView数据源绑定的一个小问题
在使用GridView绑定数据源的时候,遇到了一个问题,因为图简单,没有注意到,贴出错误截图: 找了半天没有找出错误,在网上找了之后,才发现是一个细节引起的错误. 后台是这样写的: namespace ...
- Oracle varchar2 4000
关于oracle varchar2 官方文档的描述 VARCHAR2 Data Type The VARCHAR2 data type specifies a variable-length char ...
- 1105. Spiral Matrix (25)
This time your job is to fill a sequence of N positive integers into a spiral matrix in non-increasi ...
- Hive基本命令整理
创建表: hive> CREATE TABLE pokes (foo INT, bar STRING); Creates a table called pokes with t ...
- 查看MySQL还原出来的binlog日志中内容方法
用mysqlbinlog查出需要查看的数据后,可以用more来查看: [root@yoon data]# more recover_sakila.sql | grep --ignore-case -E ...
- 微信诡异的 40029 不合法的oauth_code
最近几天在做微信公共平台开发,之前一切正常运行着,发布一套程序出去之后,发现时不时的报错! 小总结下问题出现原因:微信oauth2.0 接口说明 第一步:用户同意授权,获取code 在确保微信公众账号 ...
- 关于MDK中:RO-data、RW-data、ZI-data
最近在LPC2109上调试ENC28J60,协议栈使用的是UIP,刚开始用的telnet服务,能够正常编译运行.然后换成webserver提示: enc28j60.axf: Error: L6406E ...
- 用C#进行WinForm开发对数据库的相关操作
class SQLHelper { public SqlConnection conn; //<summary> //链接.打开数据库 //</summary> public ...