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: Top 10 records

Re: Top 10 records

From: Mark D Powell <Mark.Powell_at_eds.com>
Date: 4 Apr 2006 16:05:27 -0700
Message-ID: <1144191927.526922.157320@e56g2000cwe.googlegroups.com>


>From a database or from a table? Define TOP.

By definition a heap table is an unordered collection of rows so to assign an order you most use an order by clause.

To limit the output to the first ten rows Oracle happens to find:

select * from table_a where rownum < 11;

To find the top ten salaries in the company then something like

select ename, sal
from ( select ename, sal from emp order by sal desc ) where rownum < 11;

HTH -- Mark D Powell -- Received on Tue Apr 04 2006 - 18:05:27 CDT

Original text of this message

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