write query for fourth maximum salary from employee table

Answers were Sorted based on User's Feedback



write query for fourth maximum salary from employee table..

Answer / anish tuladhar

select
distinct salary
from
(
select
DENSE_RANK() over(order by salary desc) as rnk,
salary
from
employee
) a
where
rnk = 4

Is This Answer Correct ?    0 Yes 0 No

write query for fourth maximum salary from employee table..

Answer / prabhjeet singh sethi

select * from
(select rank(salary) over (partition by employee order by salary desc) as top_salary, employee from table
group by employee)
where top_salary = 4

Is This Answer Correct ?    0 Yes 0 No

write query for fourth maximum salary from employee table..

Answer / icedrop

 select top 1 salary from (select distinct top 4 Salary from tablename order by salary desc ) result order by salary 

Is This Answer Correct ?    0 Yes 0 No

write query for fourth maximum salary from employee table..

Answer / santhosh

;with result as
(
--use dense_rank instead of row_number or rank
select salary, DENSE_RANK() over (order by salary desc) as denserank
from Employees
)
select top 1 * from result
where denserank = 4

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL Server Interview Questions

What are the types of database recovery models?

0 Answers   HCL,


Where are magic tables stored ? Is it in the same database where it is created ?

4 Answers  


How to create and drop temp table in sql server?

0 Answers  


1. What is CUBE Operator? 2. what are the new data types are available in sql server 2008? 3. Inisde a nested queries, how many subqueries u can have?

3 Answers  


Can a table be moved to different filegroup?

0 Answers  






How to delete existing rows in a table?

0 Answers  


What is recursion? Is it possible for a stored procedure to call itself or recursive stored procedure? How many levels of sp nesting is possible?

0 Answers  


What is #table in sql server?

0 Answers  


Can sql server be linked with other servers like oracle?

0 Answers  


Why do we use stored procedures in sql server?

0 Answers  


Why transaction is important?

0 Answers  


What is partition in sql server?

0 Answers  


Categories