how to calcuate the second highest salary of he employee
Answers were Sorted based on User's Feedback
Answer / shailesh
select sal from emp where sal=(select max(sal) from emp
where sal<(select max(sal) from emp);
| Is This Answer Correct ? | 0 Yes | 1 No |
Answer / jitendra
To get nth highest Salary, use below query
SELECT TOP 1 salary
FROM (
SELECT TOP nth salary
FROM Emp
ORDER BY salary DESC
) TmpTable
ORDER BY salary ASC
Replace nth with your number like second highest=2 4th=4 etc
| Is This Answer Correct ? | 0 Yes | 3 No |
Answer / vivek ghorad
select min(select top(2)salary from emp)from emp;
| Is This Answer Correct ? | 3 Yes | 9 No |
Name some usages of database trigger?
How do I run a sql script?
Hi Everyone, How to get fist and last record from a table in oracle? Thanks in advance
What jobs use sql?
what are the different functions in sorting an array? : Sql dba
What are views in sql?
How do you truncate?
what will be the output: select 1 from emp union all select 2 from emp;
What is number function in sql?
Explain the purpose of %type and %rowtype data types?
what happens when the column is set to auto increment and you reach the maximum value for that table? : Sql dba
Does SQL*Plus contains pl/sql Engine?
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)