FastPrepConvert a Purchase at Its Historical Exchange Rate

Convert a Purchase at Its Historical Exchange Rate

Agoda logoAgoda● EasyFULLTIMEOA

Problem statement

A purchase has a price in an international currency and a timestamp. Exchange-rate changes are recorded with the timestamp at which each rate becomes effective.

Return the amount payable in internal currency by using the latest exchange rate whose timestamp is less than or equal to the purchase timestamp.

The original assessment fetched the purchase through a local REST endpoint and read the rate history from MySQL. In this practice runner, those two source inputs are supplied directly as tables.

Table schema

Pandas

Use the same input data with any supported language. Open the Schema tab in the editor to see the generated SQL setup or Pandas DataFrames.

purchase

ColumnTypeNullableDescription
product_nameTextNo—
product_priceIntegerNo—
purchase_timestampIntegerNo—

currency

ColumnTypeNullableDescription
rate_timestampPKIntegerNo—
exchange_rateIntegerNo—

Expected result

Your query or function must return these columns.

ColumnTypeNullableDescription
amount_to_payIntegerNo—

Row order: must match exactly. Numeric tolerance: 0.

Constraints

  • The purchase table contains exactly one row.
  • At least one currency row is effective at the purchase timestamp.
  • Currency timestamps are unique.

More Agoda problems

See Agoda hiring insights