use AlplaPROD_test1

select * from 
(select IdArtikelvarianten as av,
VKPreis as salesPrice, 
MPB, FWMPAlpla, 
FWMPB,
ROW_NUMBER() over(partition by IdArtikelVarianten order by gueltigabdatum desc) rn,
convert(date, gueltigabdatum, 120) as validDate 
from dbo.T_HistoryVK (nolock)
where convert(date, gueltigabdatum, 120) <= '[date]' and StandardKunde = 1) a	
where rn =1 
order by  av asc, 
validDate desc