select
sp2.Currency_ID
from
SupplierPriceLists2 sp2
join SupplierPriceLists sp on sp2.Parent_ID = sp.ID
join Seldat sld on sld.Obj_ID = sp2.StoreCard_ID and sld.Sel_ID = :Seldat_ID
where
sp.ValidFromDate$DATE in (
select b.MaxDate from LatestSupplierPriceLists2_V b
where b.StoreCard_ID = sp2.StoreCard_ID
)Generated by ABRA Software a.s. 27.10.2021 16:34:12