how to find the second highest salary from emp table?
Answers were Sorted based on User's Feedback
select salary from employees a where &nth_highest_salary =(select count(distinct salary)
from employees b where a.salary<=b.salary)
/
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / mohammed irfan
SELECT sal1 "salary"
FROM (SELECT ROWNUM rownum1 ,sal1
FROM (SELECT sal sal1
FROM emp
ORDER BY sal DESC
)
)
WHERE rownum1=:p_highest;
Note:- 'p_highest' here we can give the number as we want
to display the highest salary.
Is This Answer Correct ? | 1 Yes | 1 No |
Answer / hitesh pundir
select max(salary)from m1 where salary <>(select max(salary)
from m1)
Is This Answer Correct ? | 2 Yes | 2 No |
Answer / vinay
It works gr8...
select max(salary) from <table_name> where salary<(select
max(salary)from <table_name>)
Is This Answer Correct ? | 2 Yes | 2 No |
Answer / mallika
SELECT salary FROM employee a
WHERE &n IN (SELECT COUNT(*) FROM employee b
WHERE a.salary <= b.salary)
Is This Answer Correct ? | 2 Yes | 2 No |
Answer / neeraj
SELECT DISTINCT(SAL) FROM EMP
WHERE SAL=(SELECT MIN(SAL) FROM (SELECT SAL FROM EMP ORDER
BY SAL DESC)
WHERE ROWNUM<=2);
Is This Answer Correct ? | 2 Yes | 2 No |
Answer / sathiavathi
select max(salary) from employee where salary!=(select max
(salary) from employee);
Is This Answer Correct ? | 1 Yes | 1 No |
Answer / sarojkant
select max(salary ) from emp table where sal<(select max
(salary)from emp table)
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / sarojkant
select sal from emp
where rownum=2
order by sal desc
Is This Answer Correct ? | 0 Yes | 0 No |
how to calculate the difference between two dates? : Sql dba
How do I partition in sql?
What is the difference between join and union.
27 Answers 3i Infotech, ABC, Oracle, Polaris, TCS, XT Global,
Give the structure of the procedure ?
What are the two types of exceptions in pl/sql?
Does sql*plus have a pl/sql engine?
What is a temporal data type?
1. how to use the check option constraints in sql query..? 2.how to add data in a complex query ? 3.is it possible to use commit or rollback or savepoint in triggers...if not why please explain with examples...? 4.what is the difference between meterialized view and normal view..how to create materialized view and how to use it..? 5.what is varray...? what is the advantage of the varray ? please expalin with a simpel example..i want to load into a table (student no and name and his marks..) please give example.. 6.what are the bulk bind exceptions...how to use bulk bind and how to use bulk collect..please explain with example... 7.what is for update of and where current of ...? 8 what is the use of nowait ? 9.please give an example for nocopy in a simple plsql query 10.create an index in a table...tellme how to use the index in a where clause to do performance tunning...
what are date and time data types? : Sql dba
What are the datatypes a available in PL/SQL ?
Is sql a oracle?
Can we use ddl commands in pl sql?