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.货号

解决方案 »

  1.   

    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.货号
      

  2.   

    --try
    select b.品名,b.货号,a.进货,b.销售,b.金额 from tb2 as b inner join tb1 as a
    on a.货号=b.货号
      

  3.   

    select a.品名 , a.货号 , sum(进货) ,sum( 销售 ) ,sum(金额)
     from table1 a,table2 b 
    Where a.品名 =b.品名 and a.品名 =b.货号 group by 品名 ,货号 
      

  4.   

    select a.品名 , a.货号 , sum(a.进货) ,sum( b.销售 ) ,sum(b.金额)
     from table1 a,table2 b 
    Where a.品名 =b.品名 and a.品名 =b.货号 group by 品名 ,货号
      

  5.   

    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.货号
      

  6.   

    我的语句现在是这样的:INSERT INTO temp(品名,货号,数量x,金额x,数量j) SELECT DISTINCT isnull(a.品名,b.品名)品名,isnull(a.货号,b.货号)货号,isnull(SUM(a.数量),0)数量x,isnull(SUM(a.金额),0)金额x,isnull(SUM(b.数量),0)数量j FROM table1 as a full join table2 as b on a.品名=b.品名 AND a.货号=b.货号 AND 日期>=:a1 AND 日期<=:a2 GROUP BY a.品名,a.货号为什么还有报警:
    Capability not supported
      

  7.   

    不是:isnull(a.品名,b.品名)品名
    而是:isnull(a.品名,b.品名) 品名
    中间要有空格
      

  8.   

    你单独在查询分析器中执行sql代码,报错吗????
      

  9.   

    你改成试试:
    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();如果不行 看看表结构告诉我!
      

  10.   

    我是在C++ Builder中编的语句是:DM->Query1->SQL->Add("INSERT INTO temp(品名,货号,数量x,金额x,数量j) SELECT DISTINCT isnull(a.品名,b.品名) 品名,isnull(a.货号,b.货号) 货号,isnull(SUM(a.数量),0) 数量x,isnull(SUM(a.金额),0) 金额,isnull(SUM(b.数量),0) 数量j FROM xiaoshoutable as a full join jinhuotable as b on a.品名=b.品名 AND a.货号=b.货号 AND 日期>=:a1 AND 日期<=:a2 GROUP BY a.品名,a.货号")我没有查询分析器!!
      

  11.   

    DM->Query1->SQL->Add("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 xiaoshoutable as a full join jinhuotable as b on a.品名=b.品名 AND a.货号=b.货号 AND 日期>=:a1 AND 日期<=:a2 GROUP BY a.品名,a.货号");你试试,你是paradox还是sqlserver????
      

  12.   

    我是paradox,
    试了你的,有报警:Capability not supported
      

  13.   

    老大 
      你是paradox 好多语句不支持呀!!!如isnull
      

  14.   

    你这样吧:
      你先建一个与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 品名,货号
    -----------------------------------
    解决了吗?????
      

  15.   

    如果“delete 你的copy表;”不行你就改为 delete from 你的copy表
      

  16.   

    你的20分好难赚哟!开玩笑:)
    呵呵!谢谢对sql版的支持!!!