SQL stored proc max date issue
-
11-11-2019 - |
Question
I have a issue with getting the MAX DATE from a stored procedure.
Basically, I have a list of exchange rates with date of capture, which are captured daily stored within a table and I wish to return the latest value.
Here is the code I am working on..
select
distinct t.source_currency_code, t.target_currency_code,
'(' + t.source_currency_code + ') ' + s.currency_name as source_currency_name,
'(' + t.target_currency_code + ') ' + x.currency_name as target_currency_name,
t.converted_amount as buy_rate,
t.date_loaded as date_loaded
from texchange_rate t, tcurrency s, tcurrency x
where
s.currency_code = t.source_currency_code and
x.currency_code = t.target_currency_code
order by t.source_currency_code
My thought was to MAX(.t.date_loaded grouped by currency_code) but that does not work...
Any help is appreciated!
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow