find 2nd highest salary of person using cursor concept?

Answers were Sorted based on User's Feedback



find 2nd highest salary of person using cursor concept?..

Answer / amruta dash

select max(salary) from tbl where salary not in (select max
(salary) from tbl);

Is This Answer Correct ?    11 Yes 6 No

find 2nd highest salary of person using cursor concept?..

Answer / jcreddy

select e1.salary from employee e1
where 1 = (select count(salary) from employee e2 where
e1.salary < e2.salary)
order by marks asc
-- by changeing from '<', to '>' you will get min salary

Is This Answer Correct ?    4 Yes 0 No

find 2nd highest salary of person using cursor concept?..

Answer / manju

DECLARE authors_salary CURSOR
select top2(salary) from tb_employee order by desc salary

open author_salary
FETCH NEXT FROM authors_salary into @topsalary

Is This Answer Correct ?    4 Yes 1 No

find 2nd highest salary of person using cursor concept?..

Answer / krish

select max(sal) frem tbl where sal <(select max(sal) from tbl;

Is This Answer Correct ?    3 Yes 1 No

find 2nd highest salary of person using cursor concept?..

Answer / pawan

select * from emp a where 2=(select count(distinct(sal)) from emp b where a.sal<=b.sal);

Is This Answer Correct ?    0 Yes 0 No

find 2nd highest salary of person using cursor concept?..

Answer / b.mamatha

select * from tabl1 where salary=(select max(salary) from
tabl1 where salary<(select max(salary) from tabl1)

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More SQL Server Interview Questions

Will sql server 2005 allow you to reduce the size of a column?

0 Answers  


What is database white box testing?

0 Answers  


How reterive duplicate value in SQL?

6 Answers  


If i am handling 150 servers then how to check the active jobs of all the servers?

0 Answers  


How to encrypt Strored Procedure in SQL SERVER?

0 Answers  






What is stretch database in sql server?

0 Answers  


What is an index?

8 Answers   Yardi Software,


How data can be copied from one table to another table?

0 Answers  


How to handle error or exception in sql?

0 Answers  


how to avoid cursors? : Sql server database administration

0 Answers  


sql server syntax to add "!" sign to "name" field of "employee" table in a manner that all names have the same lenght of 20 characters

1 Answers  


Explain the architecture of SQL Server?

2 Answers   ABC, HP, Oracle,


Categories