Sobes.tech
Junior — Senior

Get the current exchange rate for a specified date

livecode

Task condition

Given a table currency_rates with the following columns:

  • cur_code (string, currency code, e.g., 'USD', 'EUR')
  • rate_date (DATE, the date for which the rate is known)
  • exchange_rate (NUMERIC, the rate value)

Only records where the rate has changed are inserted into the table. If there is no row for the requested date, the nearest previous date with an available rate should be used (for example, if there is no data for January 1st, use the rate from December 31st).

Formulate an SQL query that takes parameters cur_code and target_date and returns the current exchange rate for the currency.

Get the current exchange rate for a specified date… - sobes.tech