write query for fourth maximum salary from employee table
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
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 |
How to delete duplicate records based on single column from a table?
0 Answers Petranics Solutions,
How do I shrink an ldf file?
What is difference between inner join and join?
What do you understand by a view?
What does it mean to manipulate data?
how can you move the master database
What new changes are being made in SQL Server?
What are the differences between substr and charindex in sql server.
How to create a user name in a database?
Explain about merge replications?
How to rename an existing column with the "sp_rename" stored procedure in ms sql server?
How many types of the database links?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)