how to find the second highest salary from emp table?
Answers were Sorted based on User's Feedback
Answer / anonymous
select Max(salary) from test where salary not in(select Max
(salary) from test);
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / hemant
select salary,empname from employee where
salary=(select max(salary) from employee where
salary<(select max(salary) from employee))
This query will produce all the result whose salary is
second highest.
1. A 20000
2. B 20000
3. C 20000
4. D 20000
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / boring guy
select max(sal) from emp where sal!=(select max(sal) from
emp)
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / adithya
select min(sal) from (select distict sal from emp where
rownum<3 order by sal desc)
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / pankaj raj patel
select max(salary ) from emp table where sal<(select max
(salary)from emp table)
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / kasiraya
SELECT SALARY
FROM
(
SELECT ROW_NUMBER() OVER( ORDER BY SALARY DESC) AS
SL_NO,SALARY
FROM EMP
ORDER BY SALARY DESC
)
WHERE SL_NO=2
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / dinesh rajput
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 ? | 0 Yes | 0 No |
select *from(select *from emp orderby sal desc)where
ronum<=2 minus select *from (select *from emp order by sal
desc ) where rownum<=1;
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / bell
SELECT TOP 1 FieldName FROM (SELECT TOP 2 FieldName FROM
Tabname ORDER BY FieldName DESC) allis ORDER BY FieldName
ASC
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / ramu
selectename,sal from (select ename,sal from emp order by sal
desc) where rownum<=5;
| Is This Answer Correct ? | 0 Yes | 0 No |
What are the types of join in sql?
How well can multiple sessions access the same data simultaneously ?
How can you load multi line records? : aql loader
how to create a table index in mysql? : Sql dba
Does sap use sql?
What is compound trigger?
How do u count no of rows in a table?
How do I clear the screen in sql plus?
Can you have more than one trigger on a table?
What are nested triggers ?
6 Answers Amazon, Appeal Soft, IBM, Infosys, TCS,
How would you hide a table in sql. ie the table can be only visible to its maker?
what is a join? : Sql dba
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)