方法一:
;with tb1 as (
select M.产编,T1.日期
From 数据库Now.table M
Left outer join 数据库Now.Table出货纪录 T1 on M.产编 = T1.产编
Where 条件 T1.xx = xxx.....
),
tb2 as (
select M.产编,T1.日期
From 数据库2013.table M
Left outer join 数据库2013.Table出货纪录 T1 on M.产编 = T1.产编
Where 条件 T1.xx = xxx.....
),
tb3 as (
select * from tb1
union all
select * from tb2
)
select 产编,max(日期) as 最近日期
from tb3
group by 产编