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 / praveenpinfo
Suppose table name is EMP.
SQL> Select distinct sal from emp e1 where 2=(select
count(distinct sal) from emp e2 where e1.sal<=e2.sal);
| Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
what are set operators in sql? : Sql dba
How can I see all tables in sql?
what is online transaction processing (oltp)? : Sql dba
what are sequences
How many parts of a pl sql block are optional?
how to decrement dates by 1 in mysql? : Sql dba
List the ways to get the count of records in a table?
What is difference between inner join and self join?
What is the difference between union and union all command?
How do you determine the current isolation level? : Transact sql
Can I call a procedure inside a function?
what is a database transaction? : Sql dba
What are local and global variables and their differences?
What is full join in sql?
How do I edit a stored procedure?