Hi,
I have a requirement to select the most recent currency exchange rate records for a list of specific currencies, based on an exchange date, from a table which holds a list of historic currency exchange rates for every currency.
I have a procedure which does this like so:
;WITH currencyRateExpression AS
(
SELECT *,
ROW_NUMBER() OVER (PARTITION BY c.CUR_ID ORDER BY c.CRH_DateEffective DESC) AS cre
FROM CURRHISTORY c
WHERE c.[CRH_DateEffective] <= '2015-02-02T11:40:18'
AND c.CUR_ID IN ('EUR', 'SGD', 'USD' )
)
SELECT *
FROM currencyRateExpression
WHERE cre = 1
My question is, is there a way to write this in QuerySpec, and if so could you give me an example please?
Thanks,
Iain