Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


how to retrieve the top 3 salaries of the table using rownum

Answers were Sorted based on User's Feedback



how to retrieve the top 3 salaries of the table using rownum..

Answer / raghunanda

SELECT * FROM(SELECT * FROM EMP ORDER BY SAL DESC) WHERE ROWNUM<=3;

Is This Answer Correct ?    0 Yes 0 No

how to retrieve the top 3 salaries of the table using rownum..

Answer / d.elumalai

CREATE TABLE EMP (NAME VARCHAR2(20),SALARY NUMBER(10));

INSERT INTO EMP VALUES('AAA',10000);
INSERT INTO EMP VALUES('BBB',20000);
INSERT INTO EMP VALUES('CCC',30000);
INSERT INTO EMP VALUES('DDD',40000);
INSERT INTO EMP VALUES('EEE',50000);
INSERT INTO EMP VALUES('FFF',60000);
INSERT INTO EMP VALUES('GGG',70000);
INSERT INTO EMP VALUES('HHH',80000);
INSERT INTO EMP VALUES('III',90000);
COMMIT;

SELECT A.* FROM (SELECT name, salary FROM EMP ORDER BY salary DESC) A WHERE ROWNUM<=3;

Is This Answer Correct ?    0 Yes 0 No

how to retrieve the top 3 salaries of the table using rownum..

Answer / muneer ahamed

select rownum as rank,sal from (select rownum,sal from emp
order by sal desc)
where rownum<4

Is This Answer Correct ?    4 Yes 5 No

how to retrieve the top 3 salaries of the table using rownum..

Answer / phantom coding

select * from (select rownum as rnum,t.* from emp order by
sal desc) a where rnum < 4

the alias to rownum (i.e:rnum) should be used. If rownum is
used for the constraint then the query would return the
first three rows it hits and the results could be wrong.

Is This Answer Correct ?    1 Yes 2 No

how to retrieve the top 3 salaries of the table using rownum..

Answer / ram

Select * from emp
where emp.salary in (select emp.salary from emp
where (select distict salary
from emp order by desc null last)
where rownum <=3);

Is This Answer Correct ?    1 Yes 2 No

how to retrieve the top 3 salaries of the table using rownum..

Answer / nasir iqbal

SELECT * FROM EMP A WHERE 1=(SELECT COUNT (*) FROM EMP B
WHERE B.SAL>=A.SAL)
SELECT * FROM EMP

Is This Answer Correct ?    1 Yes 2 No

how to retrieve the top 3 salaries of the table using rownum..

Answer / debanjan rudra

select sal from (select sal from emp order by val desc)
where rownum < 4;

Is This Answer Correct ?    0 Yes 1 No

how to retrieve the top 3 salaries of the table using rownum..

Answer / ashwinee

select empnumber
from emp
where rownmum < 4 and salary in (select salary
from emp
order by salary desc)

Is This Answer Correct ?    0 Yes 2 No

how to retrieve the top 3 salaries of the table using rownum..

Answer / manivasan.s.,

select salary from salary_table
where rownum <4
order by salary desc

Is This Answer Correct ?    2 Yes 5 No

how to retrieve the top 3 salaries of the table using rownum..

Answer / sumalatha

select top 3 esal from employee order by esal desc

Is This Answer Correct ?    4 Yes 18 No

Post New Answer

More SQL PLSQL Interview Questions

How do rank () and dense_rank () differ?

0 Answers  


what is outer join? what is selef join? what is difference between them? what is cartecion join?

1 Answers   Fiserv, Herbinger, Synechron,


table - new_no old_no 2345 1234 3456 2345 5678 4567 output sud be -new_no 1234 2345 3456 4567 5678

2 Answers  


What is thread join () in threading?

0 Answers  


Can triggers stop a dml statement from executing on a table?

0 Answers  


what are tables and fields? : Sql dba

0 Answers  


Explain the the delete statements in sql?

0 Answers  


What do you mean by query optimization?

0 Answers  


Can you upgrade sql express to full sql?

0 Answers  


Name the operator which is used in the query for pattern matching?

0 Answers  


What is cursor in pl sql?

0 Answers  


Can sql function call stored procedure?

0 Answers  


Categories