现在我有两个sql,分别如下:其中需要得到第一个sql中的件数(count(distinct code))和钱(sum(money))减去第二个后的件数和钱,怎样通过一个sql来实现呢?
sql1:
select code,
(select date from c where c.code=a.code) date,
money
from a
sql2:
select code,
(select date from d where d.code=a.code) date,
money
from b不要嵌套一层以上了。谢谢!
sql1:
select code,
(select date from c where c.code=a.code) date,
money
from a
sql2:
select code,
(select date from d where d.code=a.code) date,
money
from b不要嵌套一层以上了。谢谢!
解决方案 »
- sqlplus不能用
- 如果查看索引中存储的内容?
- 如果这条记录存在,才删除(sql)
- 有没有办法通过修改oracle数据库参数来限制查询返回的记录行数?(不改变sql语句)
- 哪里有toad的免费下载?
- 求一个sql语句
- 接触ORACLE已经半年多了,现在想自己实践一个案例,从应用程序到ORACLE数据库,以及中间的接口层,哪里有这样的例子,或者我可以帮助各位
- 我在WIN2000 adserver(c4 1.7g ddr256m)上安装ORACLE8I为什么启动不了安装程序?
- toad SQLTracker 问题
- 搭建数仓抽取数据过程中,kettle提示表空间不足,请问怎么解决?中途停止建立的数据文件,offline drop后并手动删除了dbf文件后会有什么影响?
- 再咨询一条SQL语句
- 关于动态sql
--试一下:select code, c.date - b.date date, c.money - b.money money
from a, b, c
where c.code = a.code
and b.code = a.code;
--改一下:select a.code code, c.date - b.date date, c.money - b.money money
from a, b, c
where c.code = a.code
and b.code = a.code;
from a, b, c
where c.code = a.code and b.code = a.code
group by a.code
select date from c where c.code=a.code
这句返回的date是唯一值吗??
应该是下面的这句sql的返回值应该不唯一 select date from d where d.code=a.code
select a.code code, sum(c.date - d.date) date, sum(c.money - d.money) money
from a,c,d
where c.code = a.code and d.code = a.code
group by a.code