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
Can we use ddl statements in stored procedure?
Can a table contain multiple foreign key’s?
Does execute immediate commit?
What are synonyms in sql?
Which tcp/ip port does sql server run?
What are the different types of triggers?
Is coalesce faster than isnull?
What is sql indexing?
What is the source code of a program?
Do triggers have restrictions on the usage of large datatypes, such as long and long raw?
what are all different types of collation sensitivity? : Sql dba
how are mysql timestamps seen to a user? : Sql dba
What are the two types of exceptions in pl/sql?
What is schema in sql example?
what is a control file ? : Sql dba