How to get Top 10 Salaries from a Table
Answers were Sorted based on User's Feedback
Answer / meena dogra
The query will be like this:
Select distinct salary from table
order by salary desc
fetch first 10 rows only
| Is This Answer Correct ? | 31 Yes | 5 No |
Answer / shammi
SELECT *
FROM (select * from employee ORDER BY salary desc) employee2
WHERE rownum <= 10
ORDER BY rownum;
correct me if am wrong
| Is This Answer Correct ? | 3 Yes | 1 No |
Answer / regu
select distinct salary from table name hwre rownum <=10
| Is This Answer Correct ? | 6 Yes | 5 No |
Answer / shaikshavali
if u r using PL/SQL
select distinct id from subs_contacts
where rownum<=10
order by id desc
| Is This Answer Correct ? | 2 Yes | 1 No |
Answer / rajesh
db2 "Select Sal from table_name order by sal desc fetch
first 10 rows only with ur"
here i defined an isolation level with ur,so don't be confused.
| Is This Answer Correct ? | 2 Yes | 2 No |
Answer / sudhakar1.jha@gmail.com
SELECT Data.Amount FROM (
SELECT ROW_NUMBER() OVER(ORDER BY CUR_ANN_AMT DESC) AS RN,
Amount
FROM Employee_table) AS DATA
WHERE DATA.RN BETWEEN 1 AND 10 ;;;;
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / bharath
In Oracle,
select e1.* from emp e1
where &n>(select distinct(COUNT(*)) from emp e2
where e1.sal>e2.sal)order by sal;
Place where n=10
we get,
| Is This Answer Correct ? | 2 Yes | 3 No |
Answer / bharath
select sal from(select ename,sal rownum from emp orderby sal
desc group by sal,rownum)where topsal='&nth';
| Is This Answer Correct ? | 1 Yes | 2 No |
Answer / abirami
Sorry.. Answer 1 given by me is incorrect.
Correct Query is
select disntinct salary from tablename
Order by salary
Fetch first 10 rows only
| Is This Answer Correct ? | 9 Yes | 13 No |
Answer / samsunisa
select top 10 salary from table name order by salary;
| Is This Answer Correct ? | 7 Yes | 19 No |
What is rebind in db2?
Explain the EXPLAIN statement?
Suppose I have a program which uses a dynamic SQL and it has been performing well till now. Off late, I find that the performance has deteriorated. What happened?
What is a correlated sub query?
Where are plans stored?
How do I create a table MANAGER (EMP-NO, MANAGER) where MANAGER is a foreign key which references to EMP-NO in the same table? Give the exact DDL.
Define db2 and its databases?
List out the data types available.
On which levels locks can be applied?
What is the maximum length of a column name in DB2? 18 or 30 or anything other than these?
What will happen, while trying to close the closed cursor.
What are the abend codes occour in ur latest PROJECT in DB2