如何对以下脚本应用CROSS APPLY
函数?我想为每个多个记录检索TOP 1。
select s.UnitID
,p.PartNumber
,po.ProductionOrderNumber
,s.[Value] as SerialNumber
,p.Revision
,case ush.UnitStatusID
when 0
then 'Processing'
else 'Completed'
end as UnitStatusID
,ush.[Time] as LastUpdate
,ush.LooperCount
from ffpart as p
join ffProductionOrder as po
on p.ID = po.PartID
join ffUnitDetail as ud
on po.ID = ud.ProductionOrderID
join ffSerialNumber as s
on ud.UnitID = s.UnitID
join ffUnitStatusHistory as ush
on ud.UnitID = ush.UnitID
where s.[Value] in('ACNX4853'
,'ACRA3259'
,'AY1712466664'
)
order by ush.[Time] desc;
感谢您的回答..提前致谢。