有A表和B表。要算A表里A1总和值。B表有B1总和值。 ...
SQL.Add('select sum(a.a1) as aa,sum(b.b1) as bb from a,b');
...
得到a的总和和b的总和值为何各和值不对呢? 如何相减?
SQL.Add('select sum(a.a1) as aa,sum(b.b1) as bb from a,b');
...
得到a的总和和b的总和值为何各和值不对呢? 如何相减?
解决方案 »
- delphi2005中查看delphi5/7写的代码中,中文部分显示乱码。不知为何,各位大虾有没有遇到的?如何解决?急盼恢复
- 【大家帮个忙,我想中台电脑】
- 简单要死的问题,可是我就是搞不定!!
- 求函数指针语法问题解决方法,谢谢
- 如何保存报表为html格式或BMP????
- 要怎么做可以使WAV的播放速度可以控制呢??
- 如何破除超级解霸2001的时间限制?
- 报表中的中文显示问题?
- 关于函数返回值的问题,请前辈指教
- 500分送上,求一个Grid的设计方法,有源代码更好!
- TIDTcpServer的writeln函数为什么会出现I/O 105 ERROR错误?
- 高手请进,小弟跪求aod和触发器问题。。请高手帮忙!!!!!!!!!
------------
A1
----
1.0
2.0
10.0
--------------表B
----
1.0
2.0
5.0
------------------SQL语句:
select sum(acount) as 表A总数量,
sum(bcount) as 表B总数量,
sum(acount) - sum(bcount) as 两表差额
from (select sum(a1) as acount, 0 as bcount
from a
union all
select 0 as acount, sum(b1) as bcount from b) m
------------------------------------------------------------结果:
表A总数量 表B总数量 两表差额
13.0 8.0 5.0
create table #2(id int)
insert into #1 values(10)
insert into #2 values(8)select a.id- b.id as diff from #1 a ,#2 b
select sum(a.a1) as aa ,
(sum(b.b1) as bb from b)
from a
(select sum(b.b1) from b) as bb
from a