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 |
How do we use distinct statement? What is its use?
What is structural independence and why is it important?
What is a boolean in sql?
what is a trigger in mysql? Define different types of trigger. : Sql dba
What are the two parts of design view?
how to do backup entire database? : Transact sql
What is an alias command?
oracle is compiler or interpretter,can any one tell me the answer?
Why use triggers in sql?
What is difference between table and view?
Which is faster view or stored procedure?
What do you understand by pl/sql packages?
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)