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
what are tables and fields? : Sql dba
What is data control language?
What is the primary use of normalization?
What are the triggers associated with image items?
How to add, remove, modify users using sql?
What is rank dense_rank and partition in sql?
how can we find the number of rows in a table using mysql? : Sql dba
What is a column in a table?
Do we need commit after truncate?
What is the example of procedure?
What is native sql query?
Does sql use python?
What is the difference between count 1 and count (*) in a sql query?
what is the stuff function and how does it differ from the replace function? : Sql dba
What is data manipulation language?