Oracle的04作业

查询"01"课程比"02"课程成绩低的学生的信息及课程分数
select s2.sid,s2.score
from (select sid,score from sc where cid = 01)s1,
(select sid,score from sc where cid = 02)s2
where s1.sid = s2.sid and s1.score < s2.score;

查询平均成绩大于等于60分的同学的学生编号和学生姓名和平均成绩
select a1.sid,sname,"平均成绩"
from (select sid,trunc (avg(score),2) "平均成绩"  from sc group by sid having avg(score)> 60) a1,student s 
where a1.sid = s.sid;

查询所有同学的学生编号、学生姓名、选课总数、所有课程的总成绩
select s.sid,sname,"选课总数","总成绩"
from student s
left join (select sid,count(cid) "选课总数",sum(score) "总成绩" from sc group by sid) s1
on s.sid = s1.sid


查询"李"姓老师的数量
select count(tid) 
from teacher 
where tname like'李%';

查询学过"张三"老师授课的同学的信息
select * 
from student
where sid in (select sid from sc,course c,teacher t where tname = '张三' and sc.cid = c.cid and c.tid = t.tid); 


查询没学过"张三"老师授课的同学的信息
select * 
from student
where sid not in (select sid from sc,course c,teacher t where tname = '张三' and sc.cid = c.cid and c.tid = t.tid);


查询学过编号为"01"并且也学过编号为"02"的课程的同学的信息;
select *
from (select s1.sid 
from (select sid from sc where cid = 01) s1,
(select sid from sc where cid = 02) s2
where s1.sid = s2.sid) a,student s
where a.sid = s.sid

感觉学完mysql之后学习Oracle的知识容易理解懂,这作业也是能完成

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值