0
我想聯同全外側的兩個臨時表加入,但不能正常工作 和八方通只顯示#RMS值,而不#RMB!連接兩個臨時表採用全外連接
那裏的,什麼是錯誤的代碼?
(無空#RMS)
create table #RMS
(
[Year] int,
[Month] int,
sTAccount bigint,
sRemaining bigint
)
insert into #RMS(Year,Month,sTAccount,sRemaining)
select
YEAR(Date) [Year],
DATEPART(MONTH,Date) [Month],
sum(TAccount) sTAccount,
sum(Remaining) sRemaining
from
SaleInvoices
group by YEAR(Date),DATEPART(MONTH,Date)
order by YEAR(Date),DATEPART(MONTH,Date)
(#RMB沒有空,但有時#RMB月列值和#RMS月份列值是不同的)
create table #RMB
(
[Year] int,
[Month] int,
bTAccount bigint,
bRemaining bigint
)
insert into #RMB(Year,Month,bTAccount,bRemaining)
select
YEAR(Date) [Year],
DATEPART(MONTH,Date) [Month],
sum(TAccount) bTAccount,
sum(Remaining) bRemaining
from
BuyInvoices
group by YEAR(Date),DATEPART(MONTH,Date)
order by YEAR(Date),DATEPART(MONTH,Date)
select * from #RMS
Full Outer Join #RMB
on #RMS.Year=#RMB.Year and #RMS.Month=#RMB.Month
group by #RMS.Year, #RMS.Month
order by #RMS.Year, #RMS.Month
謝謝您的回答