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: easy query (?)

Re: easy query (?)

From: Bruno Thomas <bthomas_at_teaser.fr>
Date: 1997/03/09
Message-ID: <01bc2cc0$a5cc3da0$LocalHost@elliott>#1/1

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.fr
Received on Sun Mar 09 1997 - 00:00:00 CST

Original text of this message

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