advanced
Organizational Hierarchy Traversal
Write a complex recursive SQL query for a corporate structure.
📝 Conteúdo do Prompt
Assume a table `Employees` with columns `id`, `name`, `manager_id`, and `salary`. Write a recursive Common Table Expression (CTE) query that returns every employee's path from the CEO (top level) down to themselves, formatted as 'CEO > Director > Manager > Employee'. Additionally, calculate the cumulative salary sum for every distinct level of the hierarchy (e.g., total salary of all Level 1 managers, all Level 2 associates, etc.) without using window functions.