OliWatkins
New member
- Local time
- Tomorrow, 00:16
- Joined
- Feb 14, 2020
- Messages
- 3
I am making a small database program to run our club. The club members pay in one of 4 currencies when they visit our club and use our facilities. Because of the volatility of exchange rates, we set them manually and change them when needed.
I want to apply an exchange rate to a transaction based on the member’s start date.
I have done this using the below SQL. I then use this query in another query of the transactions to find how much this is in our local currency.
The query works, BUT it runs very slowly and there are only 1000 records so far. Where am I going wrong?
Thank you!
I want to apply an exchange rate to a transaction based on the member’s start date.
I have done this using the below SQL. I then use this query in another query of the transactions to find how much this is in our local currency.
The query works, BUT it runs very slowly and there are only 1000 records so far. Where am I going wrong?
Thank you!
SQL:
SELECT custdates.CustID, custdates.CustDateID, ExchangeRates.xcurrency, custdates.startdate, ExchangeRates.datetimeentered, ExchangeRates.Rate, ExchangeRates.ID
FROM custdates, ExchangeRates, (SELECT DISTINCT xcurrency FROM ExchangeRates) AS C
WHERE (((ExchangeRates.datetimeentered)=(SELECT Max(datetimeentered) FROM ExchangeRates WHERE datetimeentered<startdate and xcurrency =c.xcurrency)))
ORDER BY custdates.CustDateID, ExchangeRates.xcurrency;