TABLE A: CLASS(班级)、MONEY(钱数)、DATE(日期)
TABLE B: STUDENT(学生)、CLASS(班级)、MONEY(用钱数目)、GRADE(贫困等级)、COME(出生地)求出来自山西的、贫困等级为一级的学生用完钱后,每个班级的剩余钱数
TABLE B: STUDENT(学生)、CLASS(班级)、MONEY(用钱数目)、GRADE(贫困等级)、COME(出生地)求出来自山西的、贫困等级为一级的学生用完钱后,每个班级的剩余钱数
解决方案 »
- 查询两个表记录的同集,用什么语句
- 条件中如何应用查询的字段?
- 崩溃中。。 怎么才可以查出来、?。。
- 求助!安装oracle时没有记录服务器IE地址,如何解决?
- 怎么在导出的dmp文件中找到表空间的名称
- 怎么用execute immediate 接收不同方案返回記录集!!!
- 启动数据库时报 监听程序无法启动专用服务器进程???ORACLE 9.2.0.1.0
- 大家来探讨以下,如何使自己的★/▲更多
- ORACLE.exe 卡硬盘
- 大神求助! Oracle 12c数据库,有没有办法给普通用户权限,能让用户像sys系统用户一样,在CDB中查数据字典,能查到CDB和其他PDB的数据?
- 在Orcale里如何建立和使用临时表?
- Oracle 时间戳字段问题
--你的作业题啊?
select t1.class,t1.sum2-t2.sum1 from
(select class,sum(money) sum2 from a group by class) t1,
(select class,sum(money) sum1 from b where grade='一级' group by class) t2
where t1.class=t2.class
--少了一个条件:来自山西
select t1.class,t1.sum2-t2.sum1 from
(select class,sum(money) sum2 from a group by class) t1,
(select class,sum(money) sum1 from b where grade='一级' AND come='山西' group by class) t2
where t1.class=t2.class
from tab_a a
(select class,sum(MONEY) use_MONEY
from tab_b where come='山西' and GRADE='一级' group by class) b
where a.class=b.class
from tab_a a,tab_b b
where b.come='山西' and b.GRADE='一级' and a.class=b.class(+)
group by a.class
(select class,sum(money) sum2 from a group by class) t1,
(select class,sum(money) sum1 from b where grade='一级' AND come='山西' group by class) t2
where t1.class=t2.class这个比较清晰,推荐下。
(select class, sum(money) as money1 from a as t1),
(select class,sum(money) as money2 from b where b.come='山西' and b.grade='1' as t2)
where t1.class=t2.class group by t1.class
(select class,sum(money) sum2 from a group by class) t1,
(select class,sum(money) sum1 from b where grade='一级' AND come='山西' group by class) t2
where t1.class=t2.class
from A join
(select sum(money) MONEY,class from B where grade=1 and come='山西' group by class) k
on A.class=k.class;