how to retrieve the top 3 salaries of the table using rownum

Answer Posted / nilesh

You can also use a query like

select e.ename,e.sal from emp e where 3>(select count
(distinct(b.sal)) from emp b where b.sal>e.sal)

as explained by Kalyan Kumar in Answer 2 and for making
it parameterised u can replace 3 by &sal so that when it is
executed it will ask you a number
if you enter 3 it will give you best three salaries , if
you enter 4 it will give you best 4 salaries etc.

Is This Answer Correct ?    9 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

tell us something about heap tables. : Sql dba

605


How to place comments in pl/sql?

607


How does left join work in sql?

522


How to look at the current sql*plus system settings?

606


How insert into statements in sql?

595






Does truncate require commit?

546


How to create a menu in sqlplus or pl/sql?

613


What are the types of subqueries?

573


What language is oracle sql developer?

510


Define select, insert, create, delete, update, drop keywords

600


How do I delete a trigger?

546


Can ddl statements be used in pl/sql?

597


How many clustered indexes can you have?

538


what is clause? : Sql dba

594


what is table? : Sql dba

574