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 the types of subquery? : Sql dba
What is the process of copying data from table a to table b?
Can sql function call stored procedure?
Explain some predefined exceptions.
How do you break a loop in pl sql?
Does a join table need a primary key?
Are left and right joins the same?
Which table is left in left join?
how to return query output in html format? : Sql dba
What is before and after trigger?
What is using in sql?
Are views faster than queries?
Explain ttitle and btitle.
What does count (*) mean in sql?
What sql database should I use?