Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Finding largest key in Oracle using SQL commands?
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. ;-)
-- BillyReceived on Tue Dec 03 2002 - 23:22:50 CST
![]() |
![]() |