Write a query to find five highest salaries from EMP table.
(there is a column SALARY)
Answers were Sorted based on User's Feedback
Answer / yogesh sharma
SELECT ENAME,SALARY FROM (SELECT ENAME,SAL FROM EMP ORDER BY SALARY DESC ) WHERE ROWNUM<6;
| Is This Answer Correct ? | 77 Yes | 13 No |
Answer / priya
SELECT Rownum,emp-name,salary
FROM(SELECT emp_name,salary
FROM employees
ORDER BY salary Desc)
WHERE Rownum<=5;
| Is This Answer Correct ? | 17 Yes | 3 No |
Answer / sankarapandian
select top 5 salary from employee
order by salary desc
| Is This Answer Correct ? | 17 Yes | 8 No |
Answer / sarath
select ename,sal,SAlrank from(select ename,sal,dense_rank()
over(order by sal desc) Salrank from emp)
where salrank <=5
| Is This Answer Correct ? | 9 Yes | 2 No |
Answer / nitin umale
SELECT last_name, salary
FROM (select last_name, NVL(salary,0) salary
FROM employees
ORDER BY NVL(salary,0) DESC )
WHERE rownum<6;
| Is This Answer Correct ? | 9 Yes | 3 No |
Answer / sreenivasreddy
SELECT ROWNUM, E1.*
FROM (SELECT EName, Deptno, Sal,
DENSE_RANK()
OVER(ORDER BY Sal DESC) EmpRank
FROM Emp
GROUP BY Deptno, EName, Sal
ORDER BY EmpRank) E1
WHERE E1.EmpRank <= 5
ORDER BY ROWNUM
| Is This Answer Correct ? | 6 Yes | 2 No |
Answer / vishnu
select level,max(sal) from emp
where level<=5
group by level
connect by prior sal>sal
order by level Asc;
| Is This Answer Correct ? | 5 Yes | 3 No |
Answer / mk
SELECT ENAME,SALARY FROM (SELECT ENAME,SAL FROM EMP ORDER
BY SALARY DESC ) WHERE ROWNUM<6;
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / seetharam
select * from(select * from emp order by sal desc) where
rownum<=5;
| Is This Answer Correct ? | 3 Yes | 3 No |
Answer / amit bharane
select empid,salary
from (select empid,salary
from emp
order by sal desc)
where rownum <=5;
| Is This Answer Correct ? | 0 Yes | 0 No |
What are all different types of collation sensitivity?
What is a ddl command?
How can we connect an Android App to an Oracle database and use the PL/SQL procedural code?
What is the need of merge statement?
Which data dictionary views have the information on the triggers that are available in the database?
What is difference between a Cursor declared in a procedure and Cursor declared in a package specification ?
What is trigger in sql?
Table A Table B 1 1 2 1 3 1. Union & union all --> A Union B , A Union all B 2. Minus , Intersect --> A minus B , B Minus A , A Intersect B 3. Joins A join B , A Left Join B A Right Join B , A full Join B 4. %Type - Uses & Benifit 5. Truncate & Delete 6. Pragma Autonomus Transaction 7. how to Perform DDL from function or procedure 8. Can we have DML inside Function 9. Rank & Dense Rank diffrence 10. Water Mark in Oracle 11. Index , Can we have index in all column of table if no then why ?
how to use 'mysql' to run sql statements? : Sql dba
what is the difference between a having clause and a where clause? : Sql dba
What is difference between joins and union?
How to get second highest salary from a table
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)