how to find the second highest salary from emp table?
Answers were Sorted based on User's Feedback
Answer / vinod
SELECT MAX(SAL) FROM TEST_123 WHERE SAL NOT IN (SELECT
MAX(SAL) FROM TEST_123)
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / udayalakshmij
select emp_name,max(salary) from emp except(select max(salary) from emp);
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / amarendra swain
select max(sal) from employee
where sal not in (select max(sal) from employee )
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / shankar panda
SELECT DISTINCT(E.SALARY) FROM EMPLOYEES E WHERE 2=(SELECT COUNT(DISTINCT D.SALARY) FROM EMPLOYEE D WHERE D.SALARY >= E.SALARY)
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / sreenadh reddy
select max(sal) from emp where sal <(select max(sal) from
emp)
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / bharath konegadde
Select Emp_Name from emp_table where Id=(Select Emp_Id from Salary Order By salary Desc limit 0,1)
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / chiguru&
SELECT MAX(SALARY) FROM EMPLOYEE WHERE SALARY NOT IN
(SELECT MAX(SALARY) FROM EMPLOYEE)
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / mohan rathour
select max(e1.salary) from Emp_table e1 where e1.salary not
in (select max(e2.salary) from Emp_table e2 )
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / harish
select * from emp where 2=(select count(distinct sal) from emp s where s.sal>e.sal
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / manikishore
select * from emp e where
2 =(select count(distinct sal) from emp where e.sal<=sal);
//if you want to retrieve 3rd max(sal) then you can use 3 in place of 2,,,like that for so on..
| Is This Answer Correct ? | 1 Yes | 1 No |
How can I make sql query run faster?
How many types of triggers are there in pl sql?
How many sql commands are there?
What is Function based Index and which type of function we can use in Function base index. can we use aggregate,NVL function in Function based Index..
1 Answers Metric Stream, Polaris,
Can we perform dml in function?
What action do you have to perform before retrieving data from the next result set of a stored procedure ?
The select into statement is most often used to create backup copies of tables or for archiving records?
What is group by in sql?
how to use case expression? : Sql dba
How to sort the rows in sql.
Does pl/sql support create command?
what is 'mysqlimport'? : Sql dba
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)