select a.*,d.dwmch from fr_spkfk0819 a
join spkfk b on a.商品编号=b.spbh
left join (select dwbh,spid,row_number() over (PARTITION BY spid order by plh) row from spls_rk) c on b.spid=c.spid and c.row=1
left join mchk d on c.dwbh=d.dwbh
本文转自 qvodnet 51CTO博客,原文链接:http://blog.51cto.com/bks2015/1685766