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 |
Is sql a case sensitive language?
what are local and global variables and their differences? : Sql dba
how many triggers are allowed in mysql table? : Sql dba
what is inline view?
What is primary key and foreign key?
What is sql basics?
What is the difference between delete and truncate commands?
what are the types of subquery? : Sql dba
What is primary key sql?
How do you sort in sql?
What is the mutating table and constraining table?
What is difference between a PROCEDURE & FUNCTION ?