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: SQL Question using MAX()

Re: SQL Question using MAX()

From: Jac. _at_ xs4all <_at_>
Date: Thu, 19 Nov 1998 21:32:29 +0100
Message-ID: <731v7i$jkv$1@news2.xs4all.nl>


Hello Dave,

try this:

 select area, sum(length)
 from table_name
 group by area
 having sum(length) = (select max(sum(length)) from table_name group by area)

This works fine in my database (although naming a column 'length' isn't really a good idea).
Hope this helps.

Jac. Beekers

Dave Klinger wrote in message <36545CB4.B5D25F0F_at_bechtel.com>...
>I have a table which has multiple records for a given area, with
>multiple areas. I want to know the area that has the maximum total
>length. Example data:
>
>area length
>---- ------
>7511 42.1
>7511 22.6
>7512 12.5
>7512 10.1
>7512 11.3
>7513 19.2
>
>Result should be:
>
>area sum(length)
>----- -----------
>7511 64.7
>
>I tried using the max() function, but when I do that I can only get back
>the maximum value, but I don't know what area that value goes to.
>Anyone have any ideas?
>
>Thanks,
>Dave
>
Received on Thu Nov 19 1998 - 14:32:29 CST

Original text of this message

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