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
How to get the query of a table in sql server?
What are the requirements to use odbc connections in php scripts?
What is inline table-value user-defined function?
Explain raiserror in sql server?
how can you attach more than 20 ldf files in sql server
Tell me about joins in database system and explain each in detail.
How to get all stored procedures in sql server?
What are indexes in ms sql server?
What are the new scripting capabilities of ssms? : sql server management studio
what is difference between NULL and ISNULL in SQL Server 2008?
How do I start sql server 2017?
How do we know if any query is retrieving a large amount of data or very little data?
Do you know what is fill factor and pad index?
What is table join?
Explain the flow of creating a cube? : sql server analysis services, ssas