select IdArtikelVarianten,
ArtikelVariantenAlias,
IdRezeptur,
Menge,
IdBuchungsGrund,
Buchungsdatum,
ProduktionsLos,
IdReinheit,
ReinheitBez, HerkunftBez
from alplaprod_test1.[dbo].[V_AbfallLagerBuchungen] (nolock)
where Buchungsdatum between '[startDate] ' + (select top(1) CONVERT(char(8), StartDate, 108) as startTime from [test1_AlplaPROD2.0_Read].masterData.ShiftDefinition (nolock) where TeamNumber = 1)   
and '[endDate] ' + (select top(1) CONVERT(char(8), StartDate, 108) as startTime from [test1_AlplaPROD2.0_Read].masterData.ShiftDefinition (nolock) where TeamNumber = 1)  
and IdBuchungsGrund in (140, 240)  and BuchungsTyp = 1