How to find level of employee position using RECURSIVE COMMON TABLE EXPRESSION
- by user309381
;with Ranked(Empid,Mngrid,Empnm,RN,level) As
( select Empid,Mngrid ,Empnm ,row_number() over (order by Empid)AS RN , 0 as level from dbo.EmpMngr ),
AnchorRanked(Empid,Mngrid,Empnm,RN,level)
AS(select Empid,Mngrid,Empnm,RN ,level from Ranked ),
RecurRanked(Empid,Mngrid,Empnm,RN,level)
AS(select Empid,Mngrid,Empnm,RN,level from…