how to find the second highest salary from emp table?
Answers were Sorted based on User's Feedback
Answer / winnie
select max(sal) from emp
where sal not in (select max(sal) from emp )
Is This Answer Correct ? | 1090 Yes | 131 No |
Answer / gayathri
select max(salary ) from emp table where sal<(select max
(salary)from emp table)
Is This Answer Correct ? | 754 Yes | 97 No |
Answer / gourvendra singh
Please put the below query, u will get the second highest
salary of the table :---
select sal from(select sal from
(select distinct sal from emp order by sal desc)
where rownum<=2 order by sal asc)
where rownum=1;
Is This Answer Correct ? | 488 Yes | 264 No |
Answer / nalini
Follow the following Query, You get the second highest
salary.
SQL> Select level,Max(sal) from emp
Where level=&level connect by prior sal>sal
group by level;
SQL> Enter the level No=2 (Here enter 2 manually)
Then you will get the 2nd highest salary.
If you want 3rd Highest salary, then enter level no=3.
Is This Answer Correct ? | 208 Yes | 105 No |
select max(sal) from emp where sal < (select max(sal) from
emp)
Is This Answer Correct ? | 86 Yes | 16 No |
Answer / anuj maheshwari
select sal from emp where sal=(select max(sal) from emp
where sal<(select max(sal) from emp));
Is This Answer Correct ? | 34 Yes | 5 No |
Answer / erp_guns
SELECT MAX(sal) from emp a where &n=(select COUNT(DISTINCT
(SAL)) from emp b where a.sal<=b.sal)
Is This Answer Correct ? | 39 Yes | 22 No |
Answer / shiva kumar
select max(salary) from table01
where salary <(select max salary from table01)
in mainframe env
Is This Answer Correct ? | 27 Yes | 13 No |
second method is
select sal from emp e1 where 2=(select count(distinct(sal))
from emp e2 where e1.sal<=e2.sal);
Is This Answer Correct ? | 35 Yes | 22 No |
What is the Diff b/w Constraints and Trigeer
what is the difference between truncate and drop statements? : Sql dba
What are pl sql data types?
table structure: ---------------- col1 col2 ----- ----- 01-mar-2012 11:12:46 01-mar-2012 11:12:10 01-mar-2012 11:12:46 01-mar-2012 11:11:23 Write a query to display the result as shown below: col1 col2 ----- ----- 01-mar-2012 11:12:46 01-mar-2012 11:12:10
Which column of the user triggers data dictionary view displays the database event that will fire the trigger?
what are Dynamic SQL statements?
What is having clause in sql?
What is before and after trigger?
how to increment dates by 1 in mysql? : Sql dba
what are the different tables present in mysql, which type of table is generated when we are creating a table in the following syntax: create table employee (eno int(2),ename varchar(10)) ? : Sql dba
What is sql*plus?
What is diff between bulk collect and forall