Find 2nd Highest salery in emp table
Select* from emp where &n=
select * count from emp where (salery >=emp.salery)
Enter n value 2
These query is correct or not. Tell me any other methods.
Answer Posted / madhu sudhan g
Hii lets consider the table Salary having EMPNO,EMPSal columns
to find the 2nd higest salary
;WITH CTE(Sal,Row)
AS
(
select EMPSal,ROW_NUMBER() OVER(ORDER BY EMPSal) as Row from Salary
)
select sal as Salary from CTE where Row=2
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
what is memory-optimized nonclustered indexes
Explain about remote stored procedure?
What is dirty page?
How to change the ownership of a schema in ms sql server?
How do I create a trace in sql server?
What happens if you insert a duplicate key for the primary key column in ms sql server?
What is the cartesian product of table?
Which sql server table is used to hold the stored procedure scripts?
Do you know what is replace and stuff function in sql server?
What is tablix?
Does partitioning improve performance?
How can you hide the sql server instances?
What is the impact on other user sessions when creating indexes?
What are “lost updates”?
How to check parameter value in stored procedure sql server?