How to get Top 10 Salaries from a Table

Answers were Sorted based on User's Feedback



How to get Top 10 Salaries from a Table..

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

How to get Top 10 Salaries from a Table..

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

How to get Top 10 Salaries from a Table..

Answer / regu

select distinct salary from table name hwre rownum <=10

Is This Answer Correct ?    6 Yes 5 No

How to get Top 10 Salaries from a Table..

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

How to get Top 10 Salaries from a Table..

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

How to get Top 10 Salaries from a Table..

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

How to get Top 10 Salaries from a Table..

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

How to get Top 10 Salaries from a Table..

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

How to get Top 10 Salaries from a Table..

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

How to get Top 10 Salaries from a Table..

Answer / samsunisa

select top 10 salary from table name order by salary;

Is This Answer Correct ?    7 Yes 19 No

Post New Answer

More DB2 Interview Questions

What is a DBRM, PLAN ?

3 Answers  


What are the various locks available?

5 Answers   CTS,


What is an access path?

3 Answers  


what is difference between Plan and Package

1 Answers   Syntel,


If a table has a column "dept" (declared to have nulls) and there are 10 rows in the table of which 3 have a null value in the dept column, what will select count(*) and select count(distinct dept) return?

6 Answers  






what is Runstats? Whem will u choose to runatats?

1 Answers   Danske,


in db2, already 10 columns arie der, and i want to insert 11th column. what parameters u wil consider for insertion and how will u insert

1 Answers   TCS,


What is the COBOL picture clause of the following DB2 data types: DATE, TIME, TIMESTAMP?

3 Answers  


Do we need cursor for Count(*)?

4 Answers   iGate,


If we have 100 records in the PF, we deleted all the records then what is the Size of the PF?

2 Answers  


1. what if null values retrived from database and no null indicator mentioned in query. What is sql code.

1 Answers   Cap Gemini,


what is cursor stability?

2 Answers   IBM,


Categories