How to retrieve a second highest salary from a table?
Note:Suppose salaries are in duplicate values
eg:
Name Sal
Malli 60000
Pandi 60000
Rudra 45000
Ravi 45000
Answer Posted / mallinathabj
The Following queries to retrieve the second highest salary
SQL> select max(sal) from emp where sal<(select
max(distinct(sal)) from emp);
SQL> select min(sal) from(select distinct( sal) from emp order
by sal desc) where rownum<=2;
SQL> SELECT MAX(SAL) FROM EMP WHERE SAL NOT IN (SELECT
MAX(SAL) FROM EMP);
Is This Answer Correct ? | 12 Yes | 2 No |
Post New Answer View All Answers
What is the difference between left outer join and left join?
what is bcp? When does it used? : Sql dba
Can we write dml inside a function in sql server?
Explain what is dbms?
What is 19 null in sql?
What are pl/sql packages?
What is the process of debugging?
List the different type of joins?
What are the three forms of normalization?
What are the types of views in sql?
How many types of keys are there in sql?
What is right join in sql?
Explain cursor types?
What is the difference between explicit and implicit cursors in oracle?
what is sql in mysql? : Sql dba