how to find the second highest salary from emp table?
Answers were Sorted based on User's Feedback
Answer / shrikant
You can find nth max salary
change "limit 0,n" where n = 1,2,3...
select b.sal from (select a.sal from (select distinct sal
from emp order by sal desc) a limit 0,n) b order by sal asc
limit 0,1;
| Is This Answer Correct ? | 0 Yes | 1 No |
Answer / shivdas suryawanshi
select salary from emp where salary=(select max(salary)
from emp where salary < (selct max(salary) from emp));
| Is This Answer Correct ? | 0 Yes | 1 No |
select salary from employee order by salary DESC LIMIT(1,1)
| Is This Answer Correct ? | 0 Yes | 1 No |
select salary from employee order by salary DESC LIMIT(1,1);
| Is This Answer Correct ? | 0 Yes | 1 No |
Answer / masthan
select *from emp where sal<selct *from emp where<select *from emp
| Is This Answer Correct ? | 0 Yes | 1 No |
Answer / hridayeshwar rao
select max(age) from yd where age<(select max(age) from HK) ; /// True two table Highest
SELECT * FROM HK E1 WHERE 1 =(SELECT COUNT(DISTINCT age) FROM HK E2 WHERE E1.age < E2.age); ///Second Hightest age RT single table
select age from hk e1 where (3-1) = (select count(distinct (e2.age)) from yd e2 where e2.age>e1.age);//// same True Second Hight age RT two table
select max(age) from YD where age not in (select max(age) from YD); //second hight age in single table
Suppose that salery=age
Thanks !!!
| Is This Answer Correct ? | 0 Yes | 1 No |
Answer / abhijeet banarse
Select level,Max(sal) from emp1
Where level=&level connect by prior sal>sal
group by level;
Enter the level No=2 (Here enter 2 manually)
| Is This Answer Correct ? | 0 Yes | 1 No |
Answer / moharaj m
select max(salary) from emp where salary < (select max
(salary) from emp)
| Is This Answer Correct ? | 0 Yes | 1 No |
Answer / rajesh chauhan
sql>select max(salary)from(select salary from employee where
salary not in(select max(salary)from employee))
| Is This Answer Correct ? | 0 Yes | 1 No |
Answer / waqas
Hi for second highest record follow this link
http://www.codingresolved.com/discussion/50/how-to-get-second-highest-record-in-sql#Item_2
| Is This Answer Correct ? | 0 Yes | 1 No |
Why sql query is slow?
what is a foreign key ? : Sql dba
What does where 1/2 mean in sql?
What is sql indexing?
Where is all the data on the internet stored?
Is inner join same as self join?
What is a loop in sql?
What are the differences between in and exists clause?
What is crud stand for?
Which column in the user.triggers data dictionary view shows that the trigger is a pl/sql trigger?
What is auto increment feature in sql?
What is the max nvarchar size?
Oracle (3253)
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)