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 -> Re: Select the row with the highest value

Re: Select the row with the highest value

From: Daniel A. Morgan <damorgan_at_exesolutions.com>
Date: Sun, 20 Jan 2002 09:54:01 +0000
Message-ID: <3C4A93B9.30DF1A90@exesolutions.com>


One solution is:

SELECT field
FROM table
WHERE datefield = (

   SELECT MAX(datefield)
   FROM table);

There are others.

Daniel Morgan

Kalamaro wrote:

> Hi. I want to select the row (just one) with the highest value of a given
> column. I mean, if i have the columns "data" and "date", i need to get the
> value of "data" where "date" is the most recent (the highest value of this
> field).
>
> I've tried several ways but they don't work:
>
> "select max(date) from table" -> this selects the newest date, but i want to
> get the value of "data", and if i put
> "select data,max(date) from table" it doesn't work
> "select data from table where rownum=1 order by date desc" -> returns a bad
> value, not the last
>
> thanks
Received on Sun Jan 20 2002 - 03:54:01 CST

Original text of this message

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