select isnull(a.date1, b.date1) as 日期, sum(isnull(import, 0) - isnull(export, 0)) as 金额 from a full join b on a.date1 = b.date1 group by a.date1, b.date1 order by 日期
to:zkqbp,不好意思,最近較忙 select isnull(a.day1,b.day1) as day1,sum(isnull(import,0)-isnull(export,0)) as remain from (select day1,sum(import)as import from a group by day1) a full join (select day1,sum(export) as export from b group by day1) b on a.day1=b.day1 group by a.day1,b.day1 order by day1 你自己再試試吧,這個語句在我機子上執行是沒問題的