Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: easy query (?)
Alice Erickson <erickson_at_denebola.biostat.wisc.edu> a écrit dans l'article
> I would like the final temperature reading for each city at the end of
the
> day.
>
> EX.
> City Time Temp
> Boston 15:00 30
> Boston 24:00 10
> Phoenix 5:00 70
> Phoenix 6:00 72
>
> The resulting set should be
> Boston 24:00 10
> Phoenix 6:00 72
>
> but oracle will now allow you to use
>
> select city, max(temp), time from table
> group by city
>
> (as you are now also getting an aggregate of time)
>
Hello,
You can try :
SELECT a.city, a.time, a.temp
FROM table a
WHERE a.time = (SELECT max(b.time)
FROM table b WHERE b.city = a.city)/
May this help you.
-- BrunoThomas bthomas_at_teaser.frReceived on Sun Mar 09 1997 - 00:00:00 CST