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 |
Write a pl/sql script to display the following series of numbers: 99,96,93……9,6,3?
Difference between aggregate function and analytical function?
How do I add a database to sql?
What is the difference between local variables and global variables?
What is the best free sql database?
Explain ddl statements in pl/sql?
How do you create a unique index?
What operating systems are supported by oracle sql developer?
Why coalesce is used in sql?
If you want a column to be part of the result set, after which SQL keyword does it belong? 1. SELECT 2. FROM 3. WHERE 4. GROUP BY 5. HAVING
10 Answers HCL, TCS,
How to revise and re-run the last sql command?
Is it possible to sort a column using a column alias?
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)