select id,sum(saletotal) as saletotal from 
(select * from A union select * from B) ss
group by id;

解决方案 »

  1.   

    不行啊。
    from 后面好象不能跟 (select...)
      

  2.   

    本地数据库不能用两个 select ..................
      

  3.   


    select cc.id,sum(cc.saletotal) as saletotal from 
    (select * from A union select * from B) as cc
    group by id; 
    这样应该行,(改了别人的)
    希望楼上的兄弟不要生气 呵呵
      

  4.   

    还是不行。from 后面好象就是不能跟 (select...),这种SQL的标准是什么?什么地方能找到?
      

  5.   

    有这种语法的。建议你先去看看sql server的transact sql语法吧。查询很多用sql语法。
      

  6.   

    但最好用:select id,sum(saletotal) as saletotal where id,saletotal (select in "a","b"
    where a.id=b.id)group by id