export const prolinkQuery = `
select *  from (
    select *  
    From(select  
    V_Maschinen_ProdPlanungen.MaschinenStandort as Machine, 
    V_Maschinen_ProdPlanungen.IdProdPlanung as AlplaLabelOnline, 
    prolink.lot Prolink, 
    case when AlplaPROD_test1.dbo.V_Maschinen_ProdPlanungen.IdProdPlanung <> prolink.lot 
    Then 'IncorrectLot'
    Else 'Good' end as LotCheck
    from AlplaPROD_test1.dbo.V_Maschinen_ProdPlanungen (nolock)
    left join  
    (
    SELECT *
    FROM (SELECT IdMaschine, 
    Produktionslos as lot, 
    Startzeit as StartTime, 
    Upd_Date, 
    ROW_NUMBER() OVER (PARTITION BY IdMaschine ORDER BY Upd_Date DESC) RN_Prolink
    FROM AlplaPROD_test1.dbo.T_HistoryProduktionsdaten (nolock)
    WHERE Upd_Date BETWEEN DATEADD(DD, - 10, getdate()) AND DATEADD(DD, 1, getdate())) a
    WHERE RN_Prolink = 1
    ) as prolink on AlplaPROD_test1.dbo.V_Maschinen_ProdPlanungen.IdMaschine=prolink.IdMaschine) a 
    ) a
  `;
