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 serializable?
Does a sql server 2005 select statement require a from?
how to use DTS package in 2000,2005,2008 in sql server
what is the primary use of the model database? : Sql server administration
Explain transaction server explicit transaction?
You want to implement the many-to-many relationship while designing tables. How would you do it?
Which Model uses the SET concept
What are the drawbacks of reporting in ssrs?
Does dbcc checkdb requires db to be in single_user mode? : sql server database administration
How can sql server instances be hidden?
Can you edit the .rdl code associated with a linked report?
How do you drop an index?
Can we use where and having clause together?
How can a database be repaired?
Explain the truncate command? : SQL Server Architecture