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

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -