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 |
why sql is used as interpreter frequently rather than a compile?
How write primary and foreign key relationship between two tables without using constraints? u can use any of procedure/function/trigger and any sql?
What is difference between pls_integer and integer?
What is difference between my sql and sql?
How to trace the errors in pl/sql block code?
Is sqlite good enough for production?
What is meant by Materialized view?
2 Answers iGate, Marlabs, Polaris,
How do I clear the screen in sql plus?
What is varchar sql?
What is a CTE (Common Table Expression), and how is it different from a subquery?
Which column of the user triggers data dictionary view displays the database event that will fire the trigger?
What is crud stand for?
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)