how to find the n'th highest salary from emp ?

Answer Posted / ramaniranjan das

select top1 * from (select distinct top nth from table name
by column name ) alisa name of table order by column name

Example:-Create table tab_employee
(
Emp_id int,
Emp_name varchar(50),
Emp_salary money,
Emp_deg varchar(30),
emp_add varchar(100)
);
INSERT INTO tab_employee
VALUES ('1001','ANIL','18000','MANAGER','hyd')
Go
INSERT INTO tab_employee
VALUES ('1002','AKIL','6000','CLERK','Mub')
Go
INSERT INTO tab_employee
VALUES ('1003','VINOD','7000','SALESMAN','Bang' )
GO
INSERT INTO tab_employee
VALUES ('1004','VIKAS','8000','SALESMAN','BBSR' )
GO
INSERT INTO tab_employee
VALUES ('1005','SUNIL','15000','MANAGER','Orissa' )

select top 1 * from tab_employee where Emp_salary not in
(Select Distinct top 3 Emp_salary from tab_employee order
by Emp_salary Desc)order by Emp_salary Desc

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a data lock in oracle?

615


types of indexes and the rationale behind choosing a particular index for a situation.

1986


What are transaction isolation levels supported by oracle?

576


What is not equal to in oracle?

528


How to pass parameters to procedures?

555






What is SQL access advisor in Oracle?

632


15. Display the item_cost and then truncate it to the nearest hundred, ten, unit, tenth and hundredth.

1703


What is execute immediate in oracle?

549


What is bulk copy or bcp in oracle?

610


What privilege is needed for a user to connect to oracle server?

559


Is there any way to find out when one specific table/view/M-view is used last time. i.e. when one specific object is used in any SELECT statement.

859


How do I recompile a procedure in oracle?

527


Explain the importance of .pll extension in oracle?

555


Explain enable novalidate constraint.

597


how can we store any pdf file in oracle

1644