一、题目

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. DirectoryEntry配置IIS出现ADSI Error:未知错误(0x80005000)

    目录 问题案例 原因分析 解决问题 总结 问题案例 DirectoryEntry配置IIS,在IIS6.0下运转正常,但IIS7.0下运转会出错: System.DirectoryServices.D ...

  2. VS2010配色方案

    http://studiostyl.es/ 导入步骤:  工具------------导入和导出设置------------导入选定的环境设置------------否,仅导入新设置--------- ...

  3. WPF学习笔记 控件篇 属性整理【1】FrameworkElement

    最近在做WPF方面的内容,由于好多属性不太了解,经常想当然的设置,经常出现自己未意料的问题,所以感觉得梳理下. ps:先补下常用控件的类结构,免得乱了 .NET Framework 4.5 Using ...

  4. 1105. Spiral Matrix (25)

    This time your job is to fill a sequence of N positive integers into a spiral matrix in non-increasi ...

  5. 1094. The Largest Generation (25)

    A family hierarchy is usually presented by a pedigree tree where all the nodes on the same level bel ...

  6. [转]PLS-S-00201, identifier 'CALLDEMO.GET_EMPLOYEES' must be declared 预编译错误原因及解决办法

    $ proc sample9.pc SQLCHECK=SEMANTICS Pro*C/C++: Release 11.2.0.1.0 - Production on Tue Jan 8 15:18:4 ...

  7. win2008修改最大远程桌面连接数

    win2008修改最大远程桌面连接数 运行——gredit.msc——管理模板——windows组件——远程桌面服务——远程桌面回话主机——连接——限制连接的数量——修改为999999

  8. php必看六本书

    php和mysql web开发 PHP高级程序设计_模式.框架与测试.pdf  PHP专业项目实例开发.pdf PHP5高级应用开发实践.pdf [深入PHP面向对象.模式与实践(第2版)].(美)赞 ...

  9. easy ui datagrid 获取选中行的数据

    取得选中行数据: var row = $('#tt').datagrid('getSelected'); if (row){ alert('Item ID:'+row.itemid+" Pr ...

  10. aspnet_regiis.exe 的用法

    使用aspnet_regiis.exe注册.NET Framework 重新安装IIS以后,需要用aspnet_regiis.exe来注册.NET Framework, 如下: C:\WINDOWS\ ...