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 the difference between mysql and sql server?
Explain the use of keyword with encryption. Create a store procedure with encryption?
Find first and last day of current month in sql server
Explain “row_number()” in sql server with an example?
Do you know the isolation level that sql server support?
What is raid? : SQL Server Architecture
How to use "if ... Else if ... Else ..." Statement structures in ms sql server?
What is the purpose of forms?
What is lock escalation? : sql server database administration
How to write an inner join with the where clause in ms sql server?
What is a group function explain with an example?
What is the significance of null value and why should we avoid permitting null values?
What is difference between index and primary key?
What is BCP? When does it used in sql server 2012?
What is trigger and different types of Triggers?