Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> SQL query question
I've been stuck trying to figure this out. Any help appreciated.
I've got a table (RATES) that looks like this
City Rate Efct_date
NYC 100 19-DEC-2002 NYC 110 03-MAR-2002 CHI 75 19-DEC-2002
What I want is the most recent rate for each city.
I tried the following
SELECT city, rate, max(efct_date)
FROM rates
GROUP BY city
It doesn't like this because rate is not in the group by expression. But if I do put it in the group by expression, I get all the rates instead of just the most recent. This is probably so simple I just can't figure it out!! This is on an Oracle 8.0.6 server. Received on Tue Apr 15 2003 - 13:24:59 CDT