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
where are cookies actually stored on the hard disk? : Sql dba
what is bdb (berkeleydb)? : Sql dba
What are different sql data types?
How do you update a sql procedure?
How can I change database name in sql?
Is sql a scripting language?
What is string join?
How can I see all tables in sql?
What is t sql used for?
What is sql performance tuning?
How you can copy a file to file content and file to pl/sql table in advance pl/sql?
what is sql server agent? : Sql dba
Is big data nosql?
how to present a past time in hours, minutes and seconds? : Sql dba
How to select the Nth maximum salary from Table Emp in Oracle SQL Plus ?