sql - Get employee with third highest salary -
i need fetch details of employee third highest salary in efficient way.
my query:
select(select min(salary) (select * top (3) salary employees order salary)
is there issue in query.how can correct query.please help.
you can use rownumber:here partitioned empid avoid ties
;with cte ( select *,row_number() on (partition empid order salary desc) rownum table ) select * cte rownum=3
if want use query:
select min(salary ( select top (3) salary employees order salary )b
Comments
Post a Comment