一、题目

1.找出张三的最高分和最低分以及对应的课程名

select * from course c,mark m where c.cid=m.cid and sid =(select sid from student where sname ='张三')
and
(cmark >=all(select cmark from course c,mark m where c.cid=m.cid and sid =(select sid from student where sname ='张三'))
or
cmark <=all(select cmark from course c,mark m where c.cid=m.cid and sid =(select sid from student where sname ='张三')))

2.那些学生的各科成绩均高于张三

step1、找出有一门课成绩低于张三这门课成绩的人
step1.1、 select sid from student where sname='张三'
step1.2 select a.sid from mark a,mark b
where a.cid=b.cid and b.sid=1002 and a.cmark<b.cmark
step2、paichu step1,剩下的就是目的
step2.1、在成绩表中排除、找出剩下的sid
select sid from mark where sid not in (step1.2)
step2.2 在学生表中兑换成姓名
select sname from student where sid in(step2.1)

3.按平均成绩从高到低显示所有学生的“数学”、“英语”、“语文”三门的课程成绩(按如下形式显示:学生ID,高等数学,计算机数学,英语,有效课程数,有效平均分 )

select sid 学生id ,(select cmark from mark where cid=
(select cid from course where cname='数学') and sid=sc.sid) 数学 ,(select cmark from mark where cid=
(select cid from course where cname='英语')and sid=sc.sid) 英语,count(*) 有效课程数,avg(cmark) 有效均分
from mark sc group by sid

4.查询只选了数学和英语课的学生姓名

step1、select cid from course where cname='数学'
step1、select cid from course where cname='英语'
step3 select from mark a,mark b where a.cid=(step1)and b.cid=(step2) and a.sid=b.sid
step4 select sid from mark where sid in (step3) group by sid hving count(*)=2

5.找出计算机专业中均分最高的男生姓名

select sid from student where smajor='计算机' and ssex='男'
select sid,avg(cmark) amk from mark where sid in (step1)
group by sid
select max(amk) from (step2)
select sid from (step2) where amk =(step3)

6.找出数学和英语均分最高的男生姓名

step1 select cid from course where cname in('数学','英语')
step2 select cid from student where ssex='男'
step3 select sid from mark where sid in(step2) and cid in (step1) group by sid

7.找出个人均分大于总均分(所有人所有课程的均分)的学生姓名

step1 select avg(cmark) from mark
step2 select sid from mark group by sid having avg(cmark)>(step1)

8.上海地区哪门课的均分比福建差

step1 select sid from student where snativeplace='上海'
step2 select cid,avg(cmark)from mark where sid in=(step1) group by cid
step3 select sid from student where snativeplace='福建'
step4 select cid,avg(cmark) from mark where sid in=(step3) group by cid
step5 select * from mark a,mark b
where a.cid=(step2)and b.cid=(step4)and a.cid=b.cid and a.cid<b.cid
/*select * from mark a,mark b
where a.sid='10001'and b.cid='10002' and a.cid=b.cid and a.cid>b.cid*/

9. 求各门课程去掉一个最高分和最低分后的平均分

step1 select * from mark where cid='' order by cmark
step2 select cname,(
select avg(smark) from(
select sid,cid,cmark,rownum r from (
select * from mark m where cid='' order by cmark)
where r!=1 and r!=(select count(*)from mark m where cid=''))
j)均分 from course c

10.求2001课程去掉一个最高分和最低分后的平均分

step1 select * from mark where cid='' order by cmark
step2 select cname,(
select avg(smark) from(
select sid,cid,cmark,rownum r from (
select * from mark m where cid='' order by cmark)
where r!=1 and r!=(select count(*)from mark m where cid=''))
)from course c

Orcle数据库查询练习复习:四的更多相关文章

  1. Orcle数据库查询练习复习:三

    一.题目 1.与“张三”同乡的男生姓名 select * from student where snativeplace=(select snativeplace from student where ...

  2. Orcle数据库查询练习复习:二

    一.题目 1.找出所有成绩均低于80的学生姓名 select sname from student where sid in( ) select sname from student where si ...

  3. Orcle数据库查询练习复习:一

    一.创建数据库和表 drop table student; create table student ( sid int, sname ), sage int, ssex ), snativeplac ...

  4. 经验:什么影响了数据库查询速度、什么影响了MySQL性能 (转)

    一.什么影响了数据库查询速度 1.1 影响数据库查询速度的四个因素 1.2 风险分析 QPS:Queries Per Second意思是“每秒查询率”,是一台服务器每秒能够相应的查询次数,是对一个特定 ...

  5. 优化SQL Server数据库查询方法

    SQL Server数据库查询速度慢的原因有很多,常见的有以下几种: 1.没有索引或者没有用到索引(这是查询慢最常见的问题,是程序设计的缺陷) 2.I/O吞吐量小,形成了瓶颈效应. 3.没有创建计算列 ...

  6. 转载 50种方法优化SQL Server数据库查询

    原文地址 http://www.cnblogs.com/zhycyq/articles/2636748.html 50种方法优化SQL Server数据库查询 查询速度慢的原因很多,常见如下几种: 1 ...

  7. 【百度地图API】建立全国银行位置查询系统(四)——如何利用百度地图的数据生成自己的标注

    原文:[百度地图API]建立全国银行位置查询系统(四)--如何利用百度地图的数据生成自己的标注 摘要: 上一章留个悬念,"如果自己没有地理坐标的数据库,应该怎样制作银行的分布地图呢?&quo ...

  8. SQL模糊查询条件的四种匹配模式

    执行数据库查询时,有完整查询和模糊查询之分. 一般模糊语句格式如下: SELECT 字段 FROM 表 WHERE 某字段 LIKE 条件 其中关于条件,SQL提供了四种匹配模式: 1.% :表示任意 ...

  9. 利用C#实现分布式数据库查询

    随着传统的数据库.计算机网络和数字通信技术的飞速发展,以数据分布存储和分布处理为主要特征的分布式数据库系统的研究和开发越来越受到人们的关注.但由于其开发较为复杂,在一定程度上制约了它的发展.基于此,本 ...

随机推荐

  1. [大牛翻译系列]Hadoop(2)MapReduce 连接:复制连接(Replication join)

    4.1.2 复制连接(Replication join) 复制连接是map端的连接.复制连接得名于它的具体实现:连接中最小的数据集将会被复制到所有的map主机节点.复制连接有一个假设前提:在被连接的数 ...

  2. 如何使用js捕获css3动画

    如何使用js捕获css3动画 css3动画功能强大,但是不像js,没有逐帧控制,但是可以通过js事件来确定任何动画的状态. 下面是一段css3动画代码: #anim.enable{ -webkit-a ...

  3. jquery 在ie10中post数据,最终数据丢失的BUG修复

    最近在做项目的时候,发现ie10或者360之类套壳的浏览器(ie10) 在jquery调用post数据的时候,真实的请求并没有上传数据,原因不表,请见 http://stackoverflow.com ...

  4. C# 枚举,传入int值返回string值

    需求:1:子公司负责人2:人事3:审批人4:签批人 5:管理员  传入值为1,2,3,4,5这个数字的某一个.需要返回他们的中文描述. 一下忘记该怎么写了...后来百度下查出来了..记录下当个小工具吧 ...

  5. hive中简单介绍分区表

    所介绍内容基本上是翻译官方文档,比较肤浅,如有错误,请指正! hive中创建分区表没有什么复杂的分区类型(范围分区.列表分区.hash分区.混合分区等).分区列也不是表中的一个实际的字段,而是一个或者 ...

  6. ThinkPHP中PATHINFO模式优化

    ThinkPHP 3.1.2官方手册 第16.2章节 <隐藏index.php>中提到在Ngnix中隐藏index.php实现SEO友好的方法,其中使用了如下的代码 location / ...

  7. python之super()函数

    python之super()函数 python的构造器奇特, 使用魔方. 构造器内对基类对象的初始化同样也很奇特, 奇特到没有半点优雅! 在构造器中使用super(class, instance)返回 ...

  8. netlink---Linux下基于socket的内核和上层通信机制 (转)

    需要在linux网卡 驱动中加入一个自己的驱动,实现在内核态完成一些报文处理(这个过程可以实现一种零COPY的网络报文截获),对于复杂报文COPY下必要的数据交给用户 态来完成(因为过于复杂的报文消耗 ...

  9. iOS下日期的处理(世界标准时转本地时间)

    NSDate存储的是世界标准时(UTC),输出时需要根据时区转换为本地时间 Dates         NSDate类提供了创建date,比较date以及计算两个date之间间隔的功能.Date对象是 ...

  10. ASP.NET MVC 学习第三天

    今天来简单说一下Razor视图引擎语法相关的和视图类. 添加一个MvcTest项目,继续添加一个Home控制器,完成index的视图添加.我们就在index这里分析razor视图引擎.下面是home控 ...