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 ? | 13 Yes | 2 No |
Post New Answer View All Answers
Is sqlite thread safe?
What are all the ddl commands?
What is sql*loader?
What is sql entity?
what is 'mysqlshow'? : Sql dba
what is sql in mysql? : Sql dba
Inline the values in PL/SQL, what does it mean.?
what is a foreign key ? : Sql dba
Why we use joins in sql?
Can we call dml statement in function?
Why stored procedure is better than query?
The in operator may be used if you know the exact value you want to return for at least one of the columns.
What are the advantages of pl sql?
Describe different types of general function used in sql?
What is schema in sql example?