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

what are the different type of sql's statements ? : Sql dba

520


Does mysql_real_escape_string prevent sql injection?

537


What if we write return in procedure?

786


when MSQL8.0 is in market

1596


How do I count rows in sql query?

491






What is nested table in pl sql?

552


Is a foreign key always unique?

530


What is assignment operator in pl sql?

561


What is minus?

541


Explain locks? : Transact sql

569


How to execute a stored procedure?

559


Is pl sql useful?

537


Is full outer join same as cross join?

501


Why do we use procedures in sql?

547


Enlist the characteristics of pl/sql?

1238