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: use of ROWNUM

Re: use of ROWNUM

From: Thorsten Kettner <thorsten.kettner_at_web.de>
Date: 7 May 2007 02:03:07 -0700
Message-ID: <1178528587.683486.102150@y5g2000hsa.googlegroups.com>


On 5 Mai, 15:35, Mariano <mariano.calan..._at_gmail.com> wrote:
> Then I have this query result:
>
> >select * from analisi_ricovero WHERE id_ric=82
>
> ID_ANL ID_RIC INDATA VALORE
> 41 82 29-APR-07 11.54.17,000000 PM 43
> 41 82 29-APR-07 11.54.10,000000 PM 5
>
> Now I only need ID_ANL, ID_RIC and INDATA with MAX INDATA value, how
> can obtain it?

You want the one record with max indata time?

select id_anl, id_ric, indata, valore
from analisi_ricovero
where indata = (select max(indata) from analisi_ricovero)

Or do you want one record per id_anl and id_ric?

select id_anl, id_ric, indata, valore
from analisi_ricovero
where (id_anl, id_ric, indata) in
 (
 select id_anl, id_ric, max(indata)
 from analisi_ricovero
 group by id_anl, id_ric
 ) Received on Mon May 07 2007 - 04:03:07 CDT

Original text of this message

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