Re: SQL question

From: David Crowson <zdxc0d_at_amoco.com>
Date: Mon, 8 Nov 1993 08:59:36 GMT
Message-ID: <CG60zF.1H3_at_trc.amoco.com>


In article At7_at_netcom.com, rchance_at_netcom.com (Ray Chance) writes:
-->Gary R. Kephart (kephartg_at_ema.rockwell.com) wrote:
-->: Suppose I have a table with a key field (FIELD_A) an integer field (FIELD_B)
-->: and a bunch of other fields. How can I get the maximum FIELD_B and its FIELD_A
-->: value using one query?
-->
-->try... select field_a,field_b
--> from xx
--> where field_b = (select max(field_b)
--> from xx)
-->
But you don't need to do a subselect when you have a single and a group function in one select. You should use the 'group by' function. e.g.

Select FIELD_A,max(FIELD_B)
from XX
order by FIELD_A
group by FIELD_A
/

that should do it =%^)

---
------------------------------------------------------------------------------
David Crowson   =%^)   |"For my part, I travel not to go anywhere, but to go. 
Oracle DBA(Ver.4,5,6,7)| I travel for travel's sake. The great affair is to
Amoco Exploration      | move, to get down off this featherbed of civilisation
Ealing, London         | and to find the globe granite underneath and strewn
"My views not Amoex's" | with cutting flints" : Robert Louis Stevenson
Received on Mon Nov 08 1993 - 09:59:36 CET

Original text of this message