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
How do you exit in sql?
What is a pl/sql block?
Can we rename a column in the output of sql query?
what is text? : Sql dba
column A column b | output 10 7 | 10 5 8 | 8 7 -9 | 7 3 5 | 5 0 6 | 6 Write a sql query to print such output.
how can we repair a mysql table? : Sql dba
What is form and report?
what are the disadvantages of mysql? : Sql dba
How to select unique records from a table?
What is difference between sql and excel?
Can we use threading in pl/sql?
What is sqlite used for?
tell me about various levels of constraint. : Sql dba
Explain the working of foreign key?
what is union, minus and interact commands? : Sql dba