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: Karsten Farrell <kfarrell_at_belgariad.com>
Date: Wed, 04 Dec 2002 18:01:16 GMT
Message-ID: <MprH9.2378$tW5.41028753@newssvr13.news.prodigy.com>


Billy Verreynne wrote:
> 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

I got the impression when I read his post that he wasn't looking for something as simple as the highest (max) value, but the longest length value. Received on Wed Dec 04 2002 - 12:01:16 CST

Original text of this message

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