找唯一货号的最新单价

SQL找出一个缺单价的货号,link出一个代表的员工工号记录
(1)
select a.com_mac,c.com_ip,c.pst_no,c.occ_date as last_upt,c.type_work from #t_dbf20 a cross apply (select top 1 * from t_jl0030 b with(nolock,INDEX( IX_t_jl0030_9 )) where a.com_mac=b.com_mac order by occ_date desc) c

(2)
select a.*,po_date_lst=c.po_date,out_up_lst=c.unitcost into #t_dbf94 from #t_dbf90 a cross apply (select top 1 * from #t_dbf93 b where a.unitpart=b.item_code order by po_date desc, po_no desc) c

posted on 2025-09-17 11:11  manber  阅读(3)  评论(0)    收藏  举报

导航