View Full Version : SQL (MAX?) Query?

23 Sep 2005, 07:48 AM

I am trying to display a list from a SELECT statement which pulls information from 2 different tables to display the running total of exchange rates every week.

Here is my code so far and this works by listing all exchange rates so far:

Select c.CurrencyCode, c.Name, c.Symbol, cer.ConversionFromBase
from Currency c INNER JOIN CurrencyExchangeRate cer ON c.CurrencyID = cer.CurrencyID
where Deleted=0 and CurrencyCode <> 'GBP' order by CurrencyCode

(Key: CurrencyCode = e.g. GBP, Name = e.g. US Dollar, Symbol = e.g. $ and ConversionFromBase = e.g. 1.345234).

However, although I still want to record a history of exchange rates in the database, I only want to display the last ones from each (US$, AUS$ and EURO) to go against the pound. Please note that there is a running AutoID named CurrencyExchangeRateID from the CurrencyExchangeRate table, I wondered if this could be used to display the maximum (Or the latest Rate) for each currency?

Please can someone help!

Many Thanks,