select 
    a.id , sum(a.num) as num, a.date
into 
    temp
from
   (select * from tmp1
    union all
    select * from tmp2) a
order by
   a.id

解决方案 »

  1.   

    select 
        a.id , sum(a.num) as num, a.date
    into 
        temp
    from
       (select * from tmp1
        union all
        select * from tmp2) a
    group by
       a.id ,a.date
    order by
       a.id
      

  2.   

    select id,sum(num) as num,date
    from(
    select isnull(a.id1,b.id2) as id,
           isnull(a.num1,b.num2) as num,
           isnull(a.date1,b.date2) as date
    from tmp1 a
    full join tmp2 b
    on a.id1=b.id2)t
    group by id,date
    order by id
      

  3.   

    xluzhong(打麻将一缺三,咋办?) ( ) 信誉:100 
    我照你的语句运行,结果不对阿。。
      

  4.   

    select 
        a.id1 as id , sum(a.num1) as num, a.date1 as date
    from
       (select * from tmp1
        union all
        select * from tmp2) a
    group by
       a.id1 ,a.date1
    order by
       a.id1
    基本上和: libin_ftsafe(子陌红尘) 的语句一样