我需要一点帮助...
我有两个数据表:
select isnull(a.date, b.date), isnull(a.seller, b.seller), a.[theoretical itinerary], b.[real itinerary]
from table1 a full join table2 b
on a.date=b.date and a.seller=b.seller
我想你想要full join
:
select coalesce(t.date, r.date) as date, coalesce(t.seller, r.seller) as seller,
t.itinerary as theoretical_itinerary,
r.itinerary as real_itinerary
from theoretical t full join
real r
on t.date = r.date and t.seller = r.seller;
是coalesce()
使用full join
. 如果不包括它,那么您将看到NULL
匹配列的值。(如果只支持 SQL Server using
,那么会有一个简单的替代方案。)