Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


write the query for find the top 2 highest salary in sql
server

Answers were Sorted based on User's Feedback



write the query for find the top 2 highest salary in sql server..

Answer / saritha

select distinct top 2 salary from EMP order by salary desc

Is This Answer Correct ?    0 Yes 0 No

write the query for find the top 2 highest salary in sql server..

Answer / adiseshu

select * from (
select dense_rank() over (order by salary desc) rno,* from
employees ) as a where rno in(1,2)

Is This Answer Correct ?    0 Yes 0 No

write the query for find the top 2 highest salary in sql server..

Answer / mohan c v

select min(salary) from
(select top 2 salary from phani order by salary desc) as a

Is This Answer Correct ?    0 Yes 0 No

write the query for find the top 2 highest salary in sql server..

Answer / tanay chaudhary

select * from(select emp.*,Dense_Rank() over(order by salary desc) as ranking from emp)as e where e.ranking in(1,2)

//emp=table name
//salary=column name

Is This Answer Correct ?    0 Yes 0 No

write the query for find the top 2 highest salary in sql server..

Answer / santosh kumar

select Top 1 salary from ( select top 2 salary from
emp_table order by salary desc)temptable order by salary
desc.

Is This Answer Correct ?    13 Yes 14 No

write the query for find the top 2 highest salary in sql server..

Answer / santosh kumar

select Top 1 salary from ( select top 2 salary from
emp_table order by salary desc)temptable order by salary
asc.

Is This Answer Correct ?    11 Yes 12 No

write the query for find the top 2 highest salary in sql server..

Answer / ram murthy

SELECT TOP 1 salary FROM (SELECT DISTINCT TOP 2 salary FROM
employee ORDER BY salary DESC) a ORDER BY salary

Is This Answer Correct ?    3 Yes 4 No

write the query for find the top 2 highest salary in sql server..

Answer / neeraj sharma

select ename,sal from emp where rownum<=3 order by sal desc

Note:- every table has rownum column but it is hidden by
default you can see it by this
select rownum from your_table_name

Is This Answer Correct ?    3 Yes 4 No

write the query for find the top 2 highest salary in sql server..

Answer / vijayalaxmi m khot

select max(sal) from emp where sal=(select max(sal) from emp
where sal<(select max(sal) from emp));

Is This Answer Correct ?    1 Yes 3 No

write the query for find the top 2 highest salary in sql server..

Answer / shahid

select * from(select * from Employee order by salary desc) where rowNum<3

Is This Answer Correct ?    0 Yes 3 No

Post New Answer



More SQL Server Interview Questions

What is difference between oltp and olap?

0 Answers  


How do I view views in sql server?

0 Answers  


What are different replication agents and what's their purpose? : sql server replication

0 Answers  


What is row by row processing ?

2 Answers  


how can do you the system monitoring?

1 Answers  






Can store procedure call by user define function in SQL server?

10 Answers   HCL,


How many types of triggers are there?

0 Answers  


What is SubQuery in SQL Server 2008

0 Answers   HCL,


How to execute a sql statement using odbc_exec()?

0 Answers  


what is spatial nonclustered index

0 Answers  


How to find out name of all employees who has salary less than 200 Rs.?

8 Answers  


i have a table like this Eno ename 1 a 2 b 3 c i want to display ename and bossname from table hint boss is also an employee

3 Answers   NIIT,






Categories