一、题目

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数据库查询练习复习:二的更多相关文章

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

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

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

    一.题目 1.找出张三的最高分和最低分以及对应的课程名 select * from course c,mark m where c.cid=m.cid and sid =(select sid fro ...

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

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

  4. mongodb基础系列——数据库查询数据返回前台JSP(二)

    上篇博客论述了,数据库查询数据返回前台JSP.博客中主要使用Ajax调用来显示JSON串,来获取其中某一个字段,赋给界面中的某一个控件. 那这篇博客中,我们讲解,把后台List传递JSP展示. Lis ...

  5. 工程师技术(二):postfix基础邮件服务、postfix空客户端邮件服务、搭建mariadb数据库系统、配置一个数据库、使用数据库查询

    一.postfix基础邮件服务 目标: 本例要求在虚拟机server0上配置 postfix 基础服务,具体要求如下: 1> 监听本机的所有接口    2> 将邮件域和邮件服务主机名都改为 ...

  6. Spring Security教程(二):自定义数据库查询

    Spring Security教程(二):自定义数据库查询   Spring Security自带的默认数据库存储用户和权限的数据,但是Spring Security默认提供的表结构太过简单了,其实就 ...

  7. (十二)数据库查询处理之Query Execution(1)

    (十二)数据库查询处理之Query Execution(1) 1. 写在前面 这一大部分就是为了Lab3做准备的 每一个query plan都要实现一个next函数和一个init函数 对于next函数 ...

  8. shiro(二)自定义realm,模拟数据库查询验证

    自定义一个realm类,实现realm接口 package com; import org.apache.shiro.authc.*; import org.apache.shiro.realm.Re ...

  9. 【数据库】SQL经典面试题 - 数据库查询 - 子查询应用二

    上节课我们通过子查询,完成了查询的最高分学生的需求,今天我们来学习子查询的分类,以及通过子查询来完成工作中经常遇到一些个性化需求. 子查询概念: 一个SELECT语句嵌套在另一个SELECT语句中,子 ...

随机推荐

  1. hadoop数据流转过程分析

    hadoop:数据流转图(基于hadoop 0.18.3):通过一个最简单的例子来说明hadoop中的数据流转. hadoop:数据流转图(基于hadoop 0.18.3): 这里使用一个例子说明ha ...

  2. How to enables AX email functionality without Outlook

    /***************************************************************** (C) Copyright DENTSPLY Internatio ...

  3. C# 反射学习总结

    C#中的反射可以使得程序集和类型(类.结构.委托.接口和枚举)以及类型中的成员(方法.字段.属性.事件.参数.构造函数等)都成为变量在编程中动态调用.

  4. SQL统计——按照各种维度

    在SQLserver中可以按照各种维度进行统计,实现与EXCLE一样强大的功能. --========================== --Blog:<奔跑的金鱼> --Desc:&l ...

  5. Java中的继承和多态

    1.  什么是继承,继承的特点? 子类继承父类的特征和行为,使得子类具有父类的各种属性和方法.或子类从父类继承方法,使得子类具有父类相同的行为. 特点:在继承关系中,父类更通用.子类更具体.父类具有更 ...

  6. 在eclipse中使用jax-ws构建webservices服务端和客户端

    服务端: package com.yinfu.service; import javax.jws.WebService; import javax.xml.ws.Endpoint; @WebServi ...

  7. Careercup - Facebook面试题 - 4892713614835712

    2014-05-02 09:54 题目链接 原题: You have two numbers decomposed in binary representation, write a function ...

  8. ffmpeg 错误码

    av_read_frame, av_write_frame等 经常会返回负值也即写数据包失败.不同的负值代表不同的含义,可以根据错误码定义,定位问题. #define EPERM 1 /* Opera ...

  9. AsyncTask不能同时运行多个实例解决办法

    在项目中使用AsyncTask时,发现创建的多个实例无法同时运行,比如: AsyncTask t1 = new MyTask(); AsyncTask t2 = new MyTask(); t1.ex ...

  10. C# book

    <编写高质量代码:改善C#程序的157个建议>源码下载 http://www.cnblogs.com/luminji/archive/2011/09/20/2182265.html < ...