how to calcuate the second highest salary of he employee
Answer Posted / 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 |
Post New Answer View All Answers
How do you optimize a stored procedure in sql?
how can you see all indexes defined for a table? : Sql dba
How do you use a while loop in pl sql?
Do prepared statements prevent sql injection?
What is the best free sql database?
What is $$ in sql?
Can you skip header records while loading? : aql loader
how can we submit a form without a submit button? : Sql dba
How does rowid help in running a query faster?
what is an execution plan? When would you use it? How would you view the execution plan? : Sql dba
Can variables be used in sql statements?
what is bcp? When does it used? : Sql dba
What does pragma mean?
How many primary keys can a table have?
What is natural join in sql?