一、(Oracle中已驗證OK)
left join
(select l.* from
(select RealName,CompanyId,row_number() over (partition by CompanyId order by id desc) as rownum1 from vm_User WHERE IsAdmin=1) l
where l.rownum1 = 1 ) w
二、left join (select MAX(RealName),CompanyId, from vm_User GROUP BY CompanyId) W
三、
用OUTER APPLY
select b.* FROM a表 a
OUTER APPLY
(select TOP(1) * from b表 WHERE [Name] = a.[AName] ORDER BY BNo desc) b
原文链接:https://blog.csdn.net/sinat_36500530/article/details/105116381