SQL SERVER TUTORIAL IN DEPTH

The blog is to help users about sql server

Others

LightBlog

Breaking

Friday, 29 April 2016

April 29, 2016

Interview Question

--Get the second highest salary of HR department

select * from #employee1
select * from #department1

;with cte(empname,sal,row)
as
(
select empname,empsal,ROW_NUMBER() OVER (Order by empsal desc) AS RowNumber from #employee1 e
join #department1 d on e.depid=d.depid
where d.depname='HR'
)
select * from cte where row=2



 test