To find second largest salary in Employee table

Answers were Sorted based on User's Feedback



To find second largest salary in Employee table..

Answer / anil

select max(salary) from tbl_employee where salay <(select max(salary) from tbl_employee)

Is This Answer Correct ?    30 Yes 6 No

To find second largest salary in Employee table..

Answer / saravanakumar

SELECT MAX(SALARY) FROM EMPLOYEE WHERE SALARY NOT IN
(SELECT MAX(SALARY) FROM EMPLOYEE)

Is This Answer Correct ?    13 Yes 1 No

To find second largest salary in Employee table..

Answer / ram

select *from emp e where &n in(select count(distinct sal)
from emp m where e.sal<=m.sal);

which will ask's u like :

enter the value for n : 2 (enter 2)
gives u second highest.

Is This Answer Correct ?    4 Yes 0 No

To find second largest salary in Employee table..

Answer / amit

select max(salary) from employee where salary != (select max
(salary) from employee)

Is This Answer Correct ?    4 Yes 1 No

To find second largest salary in Employee table..

Answer / vikas kant

select Top 1 salary from emp_Table where salary in(select
Top 2 Salary from emp_Table order by salary desc)

Is This Answer Correct ?    6 Yes 4 No

To find second largest salary in Employee table..

Answer / zulfikar ali

SELECT MAX(SALARY)
FROM EMPLOYEE
WHERE SALARY NOT IN(SELECT TOP 1 SALARY FROM EMPLOYEE ORDER
BY SALARY DESC)

Is This Answer Correct ?    2 Yes 1 No

To find second largest salary in Employee table..

Answer / padmapriya

Thanks every one who replied for my question.

Is This Answer Correct ?    1 Yes 0 No

To find second largest salary in Employee table..

Answer / v rajkumar

Select min(salary)FROM emp WHERE salary IN (SELECT distinct
TOP 2 salary FROM emp ORDER BY salary desc)
OR
Select top 1 salary from (select distinct top 2 salary from
emp order by salary desc) emp order by salary

OR
select max(salary) from emp where salary <(select max
(salary) from emp)

Is This Answer Correct ?    1 Yes 0 No

To find second largest salary in Employee table..

Answer / satish

select salary from emp_Table_1 where 2= (select count(*)
form emp_Table_2 where emp_Table_2.salary < emp_Table_1.salary)

-satish

Is This Answer Correct ?    2 Yes 2 No

To find second largest salary in Employee table..

Answer / mohammad murtuza ali

select salary from employeetable where empsal is < max(salary)

Is This Answer Correct ?    4 Yes 4 No

Post New Answer

More SQL Server Interview Questions

Table - Products has number of products as below Productid ProductName 1 iPhone 2 iPad 3 BlackBerry Table - SalesPersonProduct has the below records Salespersonid productid S1 1 S1 2 S1 3 S2 1 S3 2 Write a SQL query that returns the number of sales for each product

2 Answers  


What is sql language?

0 Answers  


Can a trigger be created on a view?

0 Answers  


Consider a table with 8 rows 4 rows contains value 0 and 4 rows contains value 1.Now write a single update query to make all 0's as 1 and all 1's as 0

7 Answers   PMAM IT Services, TCS,


What's the purpose of Stored Procedure?

6 Answers   Wipro,






What is the difference between count () and rowcount ()?

0 Answers  


i want table name basis on column name.

5 Answers  


Are resultset updatable?

0 Answers  


Hi..here i would like to know the Backup and Restore models?

2 Answers   HCL,


table:employee EID ENAME MID(manager ids) 101 rama null 102 sita 101 103 siva 101 104 ganesh 103 . . . . . . for 103 ID the manager ID is 101(RAMA) and for 104 manager is SIVA if i give employee id (EID) you have to tell the manager for that EID write query? eample:if i give 102 .The query output should be manager for 102 ID that it should print RAMA as output

7 Answers  


What is identity?

0 Answers  


How to update a field in SQL after ALTERING a row?

0 Answers   Amdocs,


Categories