0 Replies Latest reply: Jul 11, 2017 11:37 AM by William Christensen RSS

    Hierarchy of Managers and Employees

    William Christensen

      How can the recursive tsql code below be written in qlik?

       

      https://blog.sqlauthority.com/2008/07/28/sql-server-simple-example-of-recursive-cte/

       

      USE AdventureWorks
      GO
      WITH Emp_CTE AS (
      SELECT EmployeeID, ContactID, LoginID, ManagerID, Title, BirthDate
      FROM HumanResources.Employee
      WHERE ManagerID IS NULL
      UNION ALL
      SELECT e.EmployeeID, e.ContactID, e.LoginID, e.ManagerID, e.Title, e.BirthDate
      FROM HumanResources.Employee e
      INNER JOIN Emp_CTE ecte ON ecte.EmployeeID = e.ManagerID
      )
      SELECT *
      FROM Emp_CTE

      GO