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 / k.prashanth
Select
ename,sal,deptno
from emp
where sal in
(select max
(sal) from emp
where
level<=5
connect by
prior sal<sal
group by level)
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / manoranjan sethy
Method 01:
---------
Select Ename, MAX (Sal) From Emp
Group by ROWNUM, Ename
Having Rownum <=5;
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / vivek dubey
this Query is wrong : " SELECT ENAME,SALARY FROM (SELECT ENAME,SAL FROM EMP ORDER BY SALARY DESC ) WHERE ROWNUM<6; " because We can not use Order by clause in SubQuery.
This Answer gives you the right data :
"
SELECT TOP 5
empsal.ENAME,
empsal.SAL
FROM
(
SELECT ENAME,SAL
FROM EMP
) AS empsal
ORDER BY empsal.SAL DESC
"
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / ajay dond
select salary from (select distinct salary from employees
order by salary desc)
where rownum<6
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / ram
select ename,salary from(select ename,salary from emp order by salary desc) where rownumber<6
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / kishore
select salery from (select salery from
emp order by salery desc) where rownum <=5 ;
| Is This Answer Correct ? | 2 Yes | 3 No |
Answer / manjunath u
select salary from(select salary from emp order by salary
desc)where rownum<=5;
| Is This Answer Correct ? | 0 Yes | 1 No |
Answer / kavitha nedigunta
select a.*
from(select empno,ename,sal
from emp
order by sal desc nulls last)a
where rownum <6
order by sal desc
| Is This Answer Correct ? | 3 Yes | 5 No |
Answer / mohammad murtuza ali
select * from emp as(empname,empsal,empdesc) where rownum<6
| Is This Answer Correct ? | 1 Yes | 4 No |
What is keys and its types?
How do I count records in sql?
How do I run pl sql in sql developer?
Can we call a function containing dml statements in a select query?
What is query optimization in sql?
what is a view? : Sql dba
What are the types of SQL Statement?
how to retrieve only duplicate values in a table
Which one of the following is a reason that an INSERT statement might cause an error instead of executing correctly? 1. The INSERT statement was attempting to insert a record into a view that was created from more than one table. 2. The INSERT statement was attempting to insert a record using a combination of constants and values from an existing table. 3. The INSERT statement was attempting to insert a record with a non-NULL value into a table that has that column defined as NULL. 4. The INSERT statement was attempting to insert a record into a table by selecting a record from that same table. 5. The INSERT statement was attempting to insert a record into a view rather than a table.
What is the result, when NULL is compared with NULL?
What is minus?
What is trigger with example?
Oracle (3253)
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)