 #For level 5; inner unions = total levels - this level; max no. of joins = total level - current level - 1; 
 (SELECT T.directReportees AS directReportees, sum(T.count) AS count
  FROM (    
-	>>>> TODO : continue from here
-	SELECT manager.directly_manages AS directReportees, 0 AS count
-    FROM person_direct_reportee manager
-    WHERE manager.person_id = (SELECT id
-                               FROM person
-                               WHERE name = "first1 last17")   
-    UNION                           
+	
+	SELECT reportee.directly_manages AS directReportees, 0 AS count
+    FROM person_direct_reportee manager
+    JOIN person_direct_reportee reportee
+    ON manager.directly_manages = reportee.person_id
+    WHERE manager.person_id = (SELECT id
+                               FROM person
+                               WHERE name = "first1 last7")
+							   
+	UNION                           
     
     SELECT depth2Reportees.person_id AS directReportees, count(depth2Reportees.directly_manages) AS count
     FROM person_direct_reportee manager 

 GROUP BY directReportees
)
UNION
(   
SELECT T.directReportees AS directReportees, sum(T.count) AS count
FROM (    
    
    SELECT manager.directly_manages AS directReportees, 0 AS count
    FROM person_direct_reportee manager
    WHERE manager.person_id = (SELECT id
                               FROM person
                               WHERE name = "first1 last117")   
    UNION
    
    SELECT reportee.person_id AS directReportees, count(reportee.directly_manages) AS count
    FROM person_direct_reportee manager
    JOIN person_direct_reportee reportee
    ON manager.directly_manages = reportee.person_id
    WHERE manager.person_id = (SELECT id
                               FROM person
                               WHERE name = "first1 last117")
    GROUP BY directReportees
    
    UNION
    
    SELECT depth1Reportees.person_id AS directReportees, count(depth2Reportees.directly_manages) AS count
    FROM person_direct_reportee manager 
    JOIN person_direct_reportee depth1Reportees
    ON manager.directly_manages = depth1Reportees.person_id
        JOIN person_direct_reportee depth2Reportees
        ON depth1Reportees.directly_manages = depth2Reportees.person_id
    WHERE manager.person_id = (SELECT id
                               FROM person
                               WHERE name = "first1 last117")
    GROUP BY directReportees
  ) AS T
 GROUP BY directReportees
)
UNION
 ( SELECT T.directReportees AS directReportees, sum(T.count) AS count
	FROM(
	
	SELECT reportee.directly_manages AS directReportees, 0 AS count

                               WHERE name = "first1 last117")
    
)

#total level=8
#current level=4

(#For level 4; inner unions = total levels - this level; max no. of joins = total level - current level - 1;
 SELECT T.directReportees AS directReportees, sum(T.count) AS count
 FROM (    
  
	SELECT manager.person_id AS directReportees, 0 AS count
