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 sql triggers used for?
Is it possible to pass parameters to triggers?
explain the options of myisamchk to improve the performance of a table. : Sql dba
What is flag in sql?
How do you write a subquery?
Why we use cross join?
Explain the difference between drop and truncate commands in sql?
What is sqlcontext?
Can 2 queries be executed simultaneously in a distributed database system?
What is t sql in sql server?
What does desc stand for?
What is query syntax?
Can we use rowid as primary key?
explain access control lists. : Sql dba
Do triggers have restrictions on the usage of large datatypes, such as long and long raw?