Re: A small SQL problem, top ten result
Date: Sun, 18 Jul 2004 14:24:17 GMT
Message-ID: <lKvKc.70291$Rf.37315_at_edtnps84>
Manfred Fischer wrote:
> Hello
>
> select ename, sal from emp order by sal desc;
>
> I want to know the top ten salaries?
>
> Do you know an appropriate SQL statement in oracle?
You want to learn about inline views. Effectively use your select statement (including the order by) to generate a virtual 'table' which is used in the 'FROM' clause of another SELECT statement. Then use Oracle's ROWNUM in the outside SELECT's WHERE clause.
Look at Oracle's documentation site (http://docs.oracle.com), view the library and look at the examples for 'inline view' available.
Consider getting yourself a copy of O'Reilly's Mastering Oracle SQL and save a huge amount of time by understanding your tool (SQL) well.
/Hans Received on Sun Jul 18 2004 - 16:24:17 CEST