select isnull(a.品名,b.品名) 品名,
isnull(a.货号,b.货号) 货号,
isnull(a.进货,0) 进货,
isnull(b.销售,0) 销售,
isnull(b.金额,0) 金额
from a full join b
on a.品名=b.品名 and a.货号=b.货号
isnull(a.货号,b.货号) 货号,
isnull(a.进货,0) 进货,
isnull(b.销售,0) 销售,
isnull(b.金额,0) 金额
from a full join b
on a.品名=b.品名 and a.货号=b.货号
isnull(a.货号,b.货号) 货号,
isnull(a.进货,0) 进货,
isnull(b.销售,0) 销售,
isnull(b.金额,0) 金额
from a full join b
on a.品名=b.品名 and a.货号=b.货号
select b.品名,b.货号,a.进货,b.销售,b.金额 from tb2 as b inner join tb1 as a
on a.货号=b.货号
from table1 a,table2 b
Where a.品名 =b.品名 and a.品名 =b.货号 group by 品名 ,货号
from table1 a,table2 b
Where a.品名 =b.品名 and a.品名 =b.货号 group by 品名 ,货号
Capability not supported
而是:isnull(a.品名,b.品名) 品名
中间要有空格
ADOQuery->SQL->setText("
INSERT INTO temp(品名,货号,数量x,金额x,数量j) SELECT isnull(a.品名,b.品名),isnull(a.货号,b.货号),isnull(SUM(a.数量),0),isnull(SUM(a.金额),0),isnull(SUM(b.数量),0) FROM table1 a full join table2 b on a.品名=b.品名 AND a.货号=b.货号 AND 日期>="+a1+" AND 日期<="+a2+" GROUP BY a.品名,a.货号");
ADOQuery->execsql;解释:
你不是显示 isnull(a.品名,b.品名) 品名
----------------------------------^^^^^可以不要
table1 as a
---------^^ 可以不要setText("...'"+a1+"'....");
-------------^^^
你用query的setText试试,但你的a1和a2要事先赋值并转换为文本型,之前的单引号不要望了delphi中转换是:datetoStr();如果不行 看看表结构告诉我!
试了你的,有报警:Capability not supported
你是paradox 好多语句不支持呀!!!如isnull
你先建一个与temp相同的表用paradox的copy工具.
将下列代码add到query中:
delete 你的copy表;
insert into 你的copy表 select 品名,货号,0 进货 ,销售,金额 from table3;
insert into 你的copy表 select 品名,货号,进货,0 销售,0 金额 from table4;
insert into temp select 品名,货号,sum(进货),sum(销售),sum(金额) from 你的copy表 group by 品名,货号
-----------------------------------
解决了吗?????
呵呵!谢谢对sql版的支持!!!