Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Max
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 50GBReceived on Mon Feb 03 2003 - 17:04:28 CST
![]() |
![]() |