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 / m haribaskar
Select Salary From Employee a Where 5=(
Select Count(Distinct Salary) From Employee b
Where a.Salary <= b.Salary )
| Is This Answer Correct ? | 25 Yes | 7 No |
Answer / kishore
select salery from (
(select salery ,rownum as num from
(select salery from employees order by salery desc)
where rownum <= 5 ))
where num = 5;
| Is This Answer Correct ? | 18 Yes | 4 No |
Answer / kavitha nedigunta
select a.ename,a.sal
from(select ename,sal,
dense_rank() over( order by sal desc nulls last) rk
from emp)a
where rk =5;
| Is This Answer Correct ? | 7 Yes | 1 No |
Answer / shashidhar
SELECT EMP_NAME (SELECT ROWNUM R,B.* FROM employee B ORDER
BY SALARY DESC) A
WHERE A.R = 5
| Is This Answer Correct ? | 4 Yes | 1 No |
Answer / ashwin
Hi, you can use following query.
select ename,sal from(select ename,sal from emp order by sal
desc)where rownum=5;
| Is This Answer Correct ? | 5 Yes | 2 No |
Answer / ajeet
SELECT first_name, salary FROM employees E1
WHERE (3) > (SELECT COUNT(DISTINCT(E2.salary))
FROM employees E2
WHERE E1.salary > E2.salary)
| Is This Answer Correct ? | 3 Yes | 1 No |
Answer / naresh
select salary from (select distinct(salary) from employee
oraderby salary desc) where rownum<=5;
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / ajeet
SELECT first_name, salary FROM employees E1
WHERE (5) = (SELECT COUNT(DISTINCT(E2.salary))
FROM employees E2
WHERE E1.salary < E2.salary)
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / mani
select first_name,sal from
(
select first_name,sal from
(
select distinct
sal from employees
order by sal desc
)
where rownum < 5
order by sal
)
where rownum<2;
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / avi007
SELECT employee_name,min(salary) FROM ( select distinct
salary from employee order by salary desc)
where rowno<6 group by employee_name;
| Is This Answer Correct ? | 2 Yes | 1 No |
Why stored procedure is faster than query?
What is pl/sql tables?
What is pl sql package?
how can you create an empty table from an existing table? : Sql dba
Can 2 queries be executed simultaneously in a distributed database system?
How many levels can subqueries be nested in a FROM clause?
how many tables will create when we create table, what are they? : Sql dba
What is a data definition language?
what is a stored procedure? : Sql dba
What is cold data?
What is latest version of sql?
How do I create an index in word?
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)