I have a table
CREATE TABLE currency_rate (
currency_id VARCHAR(3),
currency_date DATE,
currency_rate NUMERIC(16,8),
PRIMARY KEY (currency_id, currency_date)
);
and want to list the latest registered rates of all currencies.
Normally I would go about like this:
SELECT currency_rate.currency_id, currency_date, currency_rate
FROM currency_rate
WHERE (currency_rate.currency_id, currency_date) IN
(
SELECT currency_id, MAX(currency_date)
FROM currency_rate
GROUP BY currency_id
)
But MySQL doesn’t support nested selects...
How do I solve this?
The following gives me the last date but not the corresponding rate:
SELECT currency_rate.currency_id, MAX(currency_date), currency_rate
FROM currency_rate
GROUP BY currency_id
Mattias Jiderhamn
Expert Systems
[EMAIL PROTECTED]
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php