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

Home -> Community -> Usenet -> c.d.o.server -> Re: Max

Re: Max

From: <ctcgag_at_hotmail.com>
Date: 03 Feb 2003 23:04:28 GMT
Message-ID: <20030203180428.505$m8@newsreader.com>


Alain <Alain_at_o.fr> wrote:
> Thanks, but it doesn't work... because it's my fault : I haven't given
> all information :
> In fact, I have :
>
> ID TX Date
> -- -- -----
> 1 3 2002-01-01
> 1 4 2002-05-01
> 1 5 2002-03-01
> 2 7 2002-01-01
> 3 1 2002-02-01
> 3 8 2003-02-01
>
> And I would want the TX for the max(Date) only for eg ID=1...

only for ID=1 because that's the lowest ID among the highest date, or only for ID=1 because that's an a priori requirement?

In the former case,

select TX from
  (select ID, TX from table order by Date desc, ID asc) where rownum=1;

In the latter,

select TX from
  (select TX from table where ID=1 order by Date desc) where rownum=1;

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB
Received on Mon Feb 03 2003 - 17:04:28 CST

Original text of this message

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