What is the query to find nth highest salary?
What is the use of cursors?
Answers were Sorted based on User's Feedback
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 |
Answer / ram
1. nth highest salary
-> select *from emp e where &n =(select count(distinct sal)
from emp m where e.sal <= m.sal);
2. -> 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.
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.
Is This Answer Correct ? | 4 Yes | 0 No |
Answer / biswa
select distinct(e1.sal) from emp e1 where &n=(select count(distinct(e2.sal)) from emp e2 where e1.sal <=e2.sal)
Is This Answer Correct ? | 2 Yes | 0 No |
Hi Suraj,
Your SQL query is not working? so please try in oracle and
once again load to site.
Thanks for ur help.
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / venky
select * from emp e where &n=(select count(distinct(b.sal))
from emp b where e.sal=b.sal);
Is This Answer Correct ? | 1 Yes | 3 No |
Answer / tina
select min(sal)
from tablename
where sal in
(select top n-1 sal from tablename order by sal desc)
Is This Answer Correct ? | 0 Yes | 2 No |
Answer / sbvp
select * from table name where sal in ( select * from
(select distinct sal from tablename order by sal desc)
where rownum<=&n);
if there is any another query plz tell me r mail me
Is This Answer Correct ? | 2 Yes | 6 No |
Answer / sree
select sal from emp e where nth=(select count(*) from emp
where sal>e.sal);
Is This Answer Correct ? | 5 Yes | 12 No |
Explain dynamic target flat file name generation in informatica
What does refresh system mean, and what are its distinctive choice?
When do you use mapping parameters? (In which transformations)
to improve the performance of aggregator we use sorted input option and use sorter t/r befor aggregator. But here we are increasing one more cache in our mapping i.e; sorter. So how can u convince that you are increasing the performance.?
can we use mapplet as starting n ending object in mapping
TELL ME ABOUT WORK FLOW SCHEDULING?
What is primary and backup node?
i have source as Column1 101 a 101 b 101 c so i want to load target as column1 ---> 101 abc
How informatica recognizes mapping?
How do you avoid duplicate records with out using source qualifier,expression,aggrigator,sorter and lookup transformations ?
How to update source definition?
I have 1 crore record in my table and I have to load 25 L in 1st target,25L in 2nd target and 25L in 3rd target? I am new to Informatica,can anybody suggest me the idea?