I have a table exRate, which holds an exchange rate, ExcRate, start date, StartDate, and end date, EndDate. I want to write a function which brings the exchange rate into a view containing order information, where if order date, O_DATE, falls between StartDate and EndDate, I can multiply sales figures by the exchange rate of that date using the variable.
How do I write this function and use it as a variable?