How to get employee name from employee table which is the
fiveth highest salary of the table
Answers were Sorted based on User's Feedback
Answer / a g srikanth
Dear Shiv Shankar
There is a small mistake in your query
Select Salary From Employee a Where 5=(
Select Count(Distinct Salary) From Employee b
Where a.Salary <= b.Salary )
the correct one should be
Select Salary From Employee a Where 5=(
Select Count(Distinct Salary) From Employee b
Where a.Salary >= b.Salary )
please check it...
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / praveen
SELECT TOP 1 salary
FROM
(
select TOP 5 salary
FROM
employee
ORDER BY
salary DESC
) A
ORDER BY
salary
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / raghuvir
select * from employee where salary = (
select min(salary) from (
select distinct(salary) from employee
order by salary desc)
where rownum <=5)
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / ramu
select employee_name,salary from employee order by salary desc limit 1 offset 4;
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / vijay
select min(salary) from (select rownum r,e.* from employees e order by salary desc) where rownum<=5;
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / mrunali
select name from (select e.*, dense_rank() over (order by salary desc nulls last)as rn from emp e) where rn=5
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / raju t.t
select firt_name, salary from employees a where 5=(select
count(distinct salary from employees b where a.salary
<=b.salary);
| Is This Answer Correct ? | 6 Yes | 7 No |
Answer / anil alpati
SELECT employee_name FROM employee order by salary desc limit 1 offset 5 ;
| Is This Answer Correct ? | 0 Yes | 1 No |
Answer / anil alpati
Select empsal From emp order by empsal desc offset 5 limit 1;
| Is This Answer Correct ? | 0 Yes | 3 No |
What is the maximum size of sqlite database?
What is oracle sql developer?
Easy way to convert tableau "IF - ELSEIF" statements to Netezza "CASE" statements.
what is ref cursor in pl/sql?
what are null values? : Sql dba
Mention what plvcmt and plvrb does in pl/sql?
how to show all tables with 'mysql'? : Sql dba
Is there any problem if we use commit repeatedly after each dml statement in a plsq procedure ? (eg. there are 10 update stmt and using 10 commit stmt after each update stmt)
Why we use join in sql?
what are the authentication modes in sql server? How can it be changed? : Sql dba
What is t sql used for?
How do I count duplicates in sql?
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)