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 provide default values to stored procedure parameters?
Why is there a performance difference between two similar queries where one uses union and the other uses union all?
What should be the fill factor for indexes created on tables? : sql server database administration
Can a trigger be created on a view?
What is explicit mode in sql server?
Mention the differences between local and global temporary tables.
What is the full meaning of dml?
What is the maximum size of sql server database?
what are cursors? : Sql server database administration
How many database files are there in sql server 2000?what are they?
What does truncate do?
How to insert a new row into a table with "insert into" statements in ms sql server?
Explain cdc and sql injection?
What are views used for?
Suppose you want to implement the one-to-one relationships while designing tables. How would you do it?