I am trying to write an SQL query that would get the exchange rate for say Sterling to Euro.
I have tried the SQL below:
SELECT CurrencyCode,ExchangeRate FROM Currency
WHERE CurrencyCode='GBP';
I was expecting to get a list of two columns, currency name and exchange rates for sterling, but something is not right; any ideas?
So...
SELECT ExchangeRate FROM Currency WHERE CurrencyCode = 'EUR';
This would return a single column for all of the rates for EUR against other currencies.
Presuming you don't have an intermediate
ExchangeRates
table, so you're using a base currency instead, if the base currency is GBP, the query you want is:Here's a demo.