find out the second highest salary?
Answers were Sorted based on User's Feedback
Answer / digvijay
select max(salary) from emp where salary < Top Salary
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / prem
SQL> select salary from(select salary,rownum a from(select salary from employee order by salary desc))where a=2;
| Is This Answer Correct ? | 0 Yes | 0 No |
select max(salary) from employee where salary not in (select max(salary) from employee);
This worked :)
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / sujeet sinha
SELECT DISTINCT (a.sal) FROM EMP A WHERE 2 = (SELECT COUNT
(DISTINCT (b.sal)) FROM EMP B WHERE a.sal<=b.sal);
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / mukesh
Second highest Value
select max(user_id) from users
where user_id < (select max (user_id) from users)
Mukesh Narayan SIngh
09873595976
mukeshnsingh22@gmail.com
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / mahendra
SELECT max(salary) FROM Employee WHERE salary NOT IN
(SELECT max(salary) FROM Employee);
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / asit kumar sahu
SELECT DISTINCT SAL FROM EMP E1
WHERE 2=(SELECT COUNT(DISTINCT SAL) FROM EMP E2
WHERE E1.SAL <= E2.SAL);
OUTPUT= 3000
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / new
select max(salary) from users where salary not in (select max(salary) from users)
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / elumalai d
SELECT * FROM (SELECT salary FROM emp ORDER BY salary DESC) WHERE ROWNUM<3;
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / 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 |
How can we view last record added to a table?
There are three tables : E : EID,ENAME D : DID,DNAME empdept : eid, did select the employees who doesn't belong to any dep
What is a user account in oracle?
What happens to the indexes if a table is recovered?
What is Partitions in Table ?
Are truncate and delete commands same? If so why?
is there a tool to trace queries, like profiler for sql server?
hi friends, I have a table A col as status|NUM and value as open |1 open |2 close |3 close |3 the O/P should be open|close 1 |3 2 |4
Explain the concept of the DUAL table.
How are the index updates?
Why we choose emp number as primarykey?
Explain joins in oracle?