use AlplaPROD_test1

  select * from (SELECT 
      p.[IdLadePlanung]
      ,p.[Beleg] as lotNumber
      ,p.[LfdNrJeArtikelKunde] as runningNr
      ,p.[Barcode]
      ,p.[ProduktionsDatum] as productionDate
      ,p.[Add_User] as scanDate
      ,p.[Add_Date]
      ,p.[Upd_User]
      ,p.[Upd_Date]
      ,p.[IdJournalWarenPosition]
      ,p.[LieferMenge] as qty
	--   ,av.IdArtikelvarianten as article
	--   ,av.Bezeichnung as alias
      ,av.articlehumanreadableid as article
	  ,av.ArticleDescription as alias
      --,[SSCC_ReserveZiffer]
	  ,ROW_NUMBER() OVER (PARTITION BY p.[LfdNrJeArtikelKunde] ORDER BY p.upd_date DESC) AS RowNum
	  --,*

  FROM [dbo].[T_EAIJournalLieferPosition] as p (nolock)
  
--   left join
-- 	dbo.T_ProdPlanung as l on
-- 	l.IdProdPlanung = p.Beleg

left join 
[test3_AlplaPROD2.0_Read].labelling.InternalLabel as av on
	av.RunningNumber = p.[LfdNrJeArtikelKunde]
) as a

where idladeplanung in ([palLinkedToBol]) and RowNum = 1

order by runningNr
