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...


select Nth highest salary by using rownum

Answers were Sorted based on User's Feedback



select Nth highest salary by using rownum..

Answer / srinu

SELECT * FROM EMP WHERE SAL=(SELECT MIN(SAL) FROM ( SELECT
DISTINCT(SAL) FROM EMP ORDER BY SAL DESC) WHERE ROWNUM<'&N');

ANS::

EMPNO ENAME JOB MGR HIREDATE SAL
COMM DEPTNO
------ ---------- --------- ---------- --------- ----------
---------- ----------
7566 JONES MANAGER 7839 02-APR-81 2975
20

SELECT * FROM EMP WHERE SAL=(SELECT MIN(SAL) FROM ( SELECT
SAL FROM EMP ORDER BY SAL DESC) WHERE ROWNUM<'&N');



EMPNO ENAME JOB MGR HIREDATE SAL
COMM DEPTNO
------ ---------- --------- ---------- --------- ----------
---------- ----------
7788 SCOTT ANALYST 7566 19-APR-87 3000
20
7902 FORD ANALYST 7566 03-DEC-81 3000
20

Is This Answer Correct ?    8 Yes 0 No

select Nth highest salary by using rownum..

Answer / siva kumar

select rownum,empno,ename,sal from(select * from emp order by
sal desc)group by rownum,empno,ename,sal having rownum='&n'

Is This Answer Correct ?    6 Yes 2 No

select Nth highest salary by using rownum..

Answer / xxx

SELECT * FROM EMP WHERE N=(SELECT COUNT(DISTINCT SAL) FROM EMP
WHERE SAL>=e.SAL);

Is This Answer Correct ?    3 Yes 0 No

select Nth highest salary by using rownum..

Answer / welcomeashwin

SELECT * FROM HR.EMPLOYEES EMP1
WHERE &N=(
SELECT COUNT(DISTINCT(SALARY))
FROM HR.EMPLOYEES EMP2
WHERE EMP1.SALARY<=EMP2.SALARY
);

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More Database Management Interview Questions

What methods is used to commit the changes made in DataSet object?

0 Answers   Petranics Solutions,


What are the four types of database?

0 Answers  


What are the components of rdbms?

0 Answers  


What is the best database for big data?

0 Answers  


What is a clause in terms of sql?

0 Answers  


what are the differences you find when working with oracle 91 and sql server 2005?

1 Answers   Choice Solutions,


How to prevent concurrent access to my data?

0 Answers   HCL,


Explain entity, entity type, and entity set in dbms?

0 Answers  


How a Store Procedure called with a cursor out parameter.?

0 Answers   MCN Solutions,


What are Stored Procedures and When would we Use Them?

1 Answers  


State some commands of ddl in dbms?

0 Answers  


What is metadata and why should I use it?

0 Answers  


Categories