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

I need a query that retrieves info from an Oracle table and a query that retrieves info from a SQL Server table. The info has to be joined together according to Record ID numbers. I have very limited access to the Oracle database but full control of the SQL Server database.How do I join two different queries from two different databases?

1 Answers  


What does it mean to manipulate data?

0 Answers  


Give me a SQL Query to find out the second largest company?

0 Answers   Ernst Young,


What is dbcc? Give few examples.

0 Answers  


How m-m relationships are implemented?

2 Answers  






How to delete particular value in the column of a table.Is it possible or not?if possible give it as in query.

8 Answers   Intelenet,


How to include date and time values in sql statements?

0 Answers  


Can we move Resource database from one path to another? If yes,How can we?

1 Answers   Wipro,


Explain query editor regions

0 Answers  


What are the features of Embedded SQL

0 Answers   HCL,


What is sql server query analyzer?

0 Answers  


How to know whether our backup is succesfully taken?

1 Answers  


Categories