select Nth highest salary by using rownum
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
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 |
Explain the terms ‘record’, ‘field’ and ‘table’ in terms of database.
Are Constraints exported through Export command?
What do you mean by e-r model & object-oriented model?
What is metadata and why should I use it?
How the status of the Rollback segment can be viewed ?
What is mean by dbms?
What are ACID properties?
11 Answers Amazon, Cap Gemini,
8. Sort, Lookup What kind of technique (partition) is used? 9. How can you handle exceptions in job sequencer? 10. How do you apply custom conditions an exceptions (How do you trigger exceptions in job sequence?) 11. I have a job with 3 possibilities? Finish with ok…..Abort…….Warning} How do you handle these in Job sequencer 12. How do you connect both OK and Warning can we? 13. How to find which process is running currently? 14. How do you find the disk usage in UNIX? 15. How do you combine 2 sequential files having same metadata of same file names? 16. How do you implement SCD in Ds? 17. Explain the situation where you have applied? 18. How do you apply new changes to? 19. Difference between change capture and Change apply? 20. Explain Compare Stage? 21. What is Surrogate key? 22. How to solve the problem of null values?
What do you mean by fill factor concept with respect to indexes?
What is procedure in dbms?
What are the main features of a database?
What are the 4 main objects of a database?
Oracle (3259)
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)