What is the query to find nth highest salary?
What is the use of cursors?
Answer Posted / suraj kedia
There are 3 ways to find out the nth highest salary in a
given table (e.g. emp) as below;
1) select distinct sal from emp e1 where &n=(select count
distinct sal from emp e2 where e1.sal <=e2.sal);
2) select empno,enaame,sal,deptno,rank () over (order by sal
desc) as ra from emp where ra=&n;
3) select empno,enaame,sal,deptno,dense_rank () over (order
by sal desc) as ra from emp where ra=&n;
All the above methods are tried n tested....it works
successfully.
What is a Cursor.
When a query is executed in oracle, a result set is produced
and stored in the memory. Oracle allows the programmer to
access this result set in the memory through cursors.
Why use a cursor?
Many times, when a query returns more than one row as a
result, we might want to go through each row and process the
data in different way for them. Cursor is handy here.
Types of cursors:
Oracle PL/SQL declares a cursor implicitly for all queries
and DML statements (including queries that return only one
row). But in most of the cases we don’t use these cursors
for queries that return one row. Based on this, there are 2
types of cursors
1. Explicit cursor
2. Implicit cursor
| Is This Answer Correct ? | 13 Yes | 2 No |
Post New Answer View All Answers
How do you change a non-reusable transformation to reusable transformation?
what are the deliverables?in your project?
can u give example for factless fact table
What is exclusive and normal mode for repository services?
Different circumstance which drives informatica server to expel records?
Please let me know how to make Data masking in informatica..
How to handle decimal places while importing a flatfile into informatica?
Write the prerequisite tasks to achieve the session partition?
What is Data Caches size?
Why update strategy and union transformations are active? Explain with examples.
I have three same source structure tables. But, I want to load into single target table. How do I do this? Explain in detail through mapping flow.
How can we use mapping variables in informatica?
I am not able to connect to the domain with the client although all services and databases are up and there is no network issue?
Enlist the various types of transformations.
What is the function of union transformation?