select '200505' time,(select sum(num) from tbl_200504 where time<='200504')-(select sum(num) from tbl_200505 where time<='200504') num from dual;

解决方案 »

  1.   

    select a.sum1-b.sum2 from
    (select sum(num) sum1 from tbl_200504 where time<=to_date('200504','yyyymm)) a,
    (select sum(num) sum2 from tbl_200505 where time<to_date('200505','yyyymm)) b;
      

  2.   

    select (select max(time) from tbl_200505) as thismonth,
    sum(a.num)-sum(b.num) from tbl_200505 a,tbl_200504 b 
    where a.time<=(select max(time) from tbl_200505) 
    and b.time <(select max(time) from tbl_200505)