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 fetch common records from two tables? : Sql dba
Does truncate require commit?
Is a table valued function object?
what is the output of this query selet * from employee where 1=2 ??
What is rename in sql?
Is foreign key mandatory?
What is the difference between DELETE, TRUNCATE, and DROP?
What is posting?
How many unique keys can a table have?
Is sqlexception checked or unchecked?
What does the file extension accdb stand for?
What are the events on which a database trigger can be based?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)