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: Finding largest key in Oracle using SQL commands?

Re: Finding largest key in Oracle using SQL commands?

From: Billy Verreynne <vslabs_at_onwe.co.za>
Date: Wed, 04 Dec 2002 07:22:50 +0200
Message-ID: <ask3is$jh3$1@ctb-nnrp2.saix.net>


Keith Lee wrote:

> Does anyone know how to find the largest key in an Oracle database using
> SQL commands? I could open use a PL/SQL procedure to loop through the
> table until I get to the largest key; but, I was wondering if there was
> any SQL command to do this.

You're looking for the MAX() function.

Something like:
SELECT MAX(age) FROM employees

..which will give you the age of the oldest employee(s).

I suggest that you spend some time with the Oracle SQL manual - SQL can do some pretty impressive stuff without needing to resort to PL/SQL or other languages.

Remember that the secret of data processing in a database, is to let the database do all the work. SQL does exactly that. As soon as you use PL/SQL or any other language, _you_ do the processing with your code. Most of the time, this will be row-by-row processing. And several orders of magnitude slower than using SQL.

So little grasshopper, the better you know SQL, the better your database kung fu. ;-)

--
Billy
Received on Tue Dec 03 2002 - 23:22:50 CST

Original text of this message

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