Unanswered: Select record based on the max value of 2 columns
I have a problem, which I would think is quite simple.
I have a table with foreign exchange rates posted at different time intervals. What I would like to do is pick the most recent exchange rate for each currency.
I have tried to create an example of my table below:
First you need a Group query to return the last entry for each currency, something like this
SELECT Currency, Max(Years) as LastYear, Max(Months) as LastMonth FROM TableName GROUP BY Currency
You then need to INNERR JOIN this back to the table on Currency, year and month respectively (this assumes that there is only one entry per month per year per currency - the PK?). from this second query will then return the last record for each currency ie. the last FX_value.