( SELECT EMP_ID, EMP_DB, 1(INTEGER) FROM EMP WHERE EMP_ID = 11 UNION ALL SELECT E.EMP_ID, E.EMP_DB, R.LEVEL+1 FROM EMP E INNER JOIN RECEMP R ON E.EMP_ID = R.EMP_DB ) SELECT EMP_ID, EMP_DB, LEVEL FROM RECEMP ;
Trying to understand recursion, and I think I basically have it, but I am confused by the presence of the 1(INTEGER) in the 1st SELECT. Is this simply saying that this employee_id is the highest grade/band/level? If so, why would we not simply return the actual grade/band/level? I am pretty sure I am not understanding that part.
Also, as I see this, we are starting at a high grade and then finding those employees under EMP_ID 11. What if I wanted to start with, say, a contact centre advisor and work my way up to the MD through the hierarchy?