不知道是不是这样呢select a.ID as ID, (a.num+b.num) as num from t1 a, t2 b where a.ID=b.ID order by num desc

解决方案 »

  1.   

    select num from (select (a.num+b.num) num from t1 a,t2 b where a.id=b.ID UNION select num from t1 where id not in(select t1.id from t1 a,t2 b where a.id=b.ID) UNION select num from t2 where id not in(select t1.id from t1 a,t2 b where a.id=b.ID)) order by num desc
      

  2.   

    select id,sum(num) num from (select * from t1 union select * from t2) a group by id order by 2 desc; 呵呵,谢谢
    结贴