Joining on hierarchy

The following example shows a transitive join on hierarchy.

This query returns the number of reports in each manager's Org. (Org is a managed attribute representing organizational structure.)

RETURN SELECT
   COUNT(1) AS TotalMembers,
   manager.Org AS Org
FROM People manager
   JOIN People report
   ON IS_ANCESTOR(manager.Org, report.Org)
GROUP BY Org