select * from a left join b on a.ID = b.ID where not exists (select 1 from b t where t.ID = b.ID and t.TimeEnd > b.TimeEnd) 转载于:https://www.cnblogs.com/ulex/archive/2011/12/13/2285652.html