Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: use of ROWNUM
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
![]() |
![]() |