Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> SQL query question

SQL query question

From: John Cunningham <shortseller12_at_yahoo.com>
Date: 15 Apr 2003 11:24:59 -0700
Message-ID: <9f8bd1ef.0304151024.62eed3e4@posting.google.com>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US