find out the second highest salary?

Answer Posted / elumalai d

CREATE TABLE emp(ID NUMBER(10),NAME VARCHAR2(100),salary NUMBER(10));

INSERT INTO emp VALUES(100,'Steven',40000);
INSERT INTO emp VALUES(101,'Smith',30000);
INSERT INTO emp VALUES(102,'Ranshow',70000);
INSERT INTO emp VALUES(103,'Handscomp',20000);
INSERT INTO emp VALUES(104,'Mitchel',10000);
INSERT INTO emp VALUES(105,'Clarke',90000);
INSERT INTO emp VALUES(106,'Ponting',50000);
INSERT INTO emp VALUES(107,'Clarke',80000);
INSERT INTO emp VALUES(108,'Marsh',60000);
COMMIT;

SELECT salary FROM emp ORDER BY salary DESC;

--Records
--======
90000
80000
70000
60000
50000
40000
30000
20000
10000

SELECT min(salary) FROM (SELECT salary FROM emp ORDER BY salary DESC) WHERE ROWNUM<3;

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 the Tune Query

1845


What is pragma autonomous transaction in oracle?

516


How to create a stored program unit?

580


What is oracle rowcount?

578


What is SQL Tuning Advisor in Oracle?

633






How to list all user accounts in oracle?

612


How can you merge two tables in oracle?

567


Is the After report trigger fired if the report execution fails ?

2402


How to connect to the server with user account: sys?

564


Explain the use of owner option in exp command.

569


Explain user account with reference to oracle.

533


State and explain about oracle instance?

549


Which is faster join or subquery in oracle?

535


What is a initialization parameter file in oracle?

584


What is an oracle table?

556