how to find the second highest salary from emp table?
Answer Posted / hitesh pundir
elect max(salary) from m1 where salary not in (select top
n-1 salary from m1 order by salary desc)
-->note where n=number as we want
to display the highest salary.
ex for 2nd highest salary-->
select max(salary) from m1 where salary not in (select top 1
salary from m1 order by salary desc)
ex for 3rd highest salary-->
select max(salary) from m1 where salary not in (select top 2
salary from m1 order by salary desc)
| Is This Answer Correct ? | 4 Yes | 1 No |
Post New Answer View All Answers
How to place comments in pl/sql?
what is meant by nl2br()? : Sql dba
How do I find duplicates in two columns?
What is difference between inner join and cross join?
what is csv? : Sql dba
What is compute?
What is use of trigger?
Explain the purpose of %type and %rowtype data types?
How to start the command-line sql*plus?
how to get help information from the server? : Sql dba
What has stored procedures in sql?
- Types of triggers - View - Dcl - Procedures, packages, functions - Metasolve - Can use Dcl in triggers - package case study - Cursor and its types - triggers schedule - Wrap - Why we are using fetch and for in cursor. difference?
What is sql indexing?
What is trigger types of trigger?
If a cursor is open, how can we find in a pl/sql block?