22,210
社区成员
发帖
与我相关
我的任务
分享
;with f as
(
select ID,[time] from tab1 union all select ID,[time] from tab2
)
select * from f t where time=(select max(time) from f where id=t.id)
select ID,max([time]) as [time] into #Tab
from (select ID,[time] from tab1 union all select ID,[time] from tab2 )t group by ID
select * into #Tab from Tab1
update a set [time]=b.[time]
from #Tab a join Tab2 b on (a.id=b.id)
where [time]<b.[time]
select ID,max([time]) as [time]
into #Tab
from (select ID,[time] from tab1
uinon all
select ID,[time] from tab2
)t
group by ID