VIP 👤
🏠 Strona Główna
Benchmarki
📊 Wszystkie benchmarki 🦖 Dinozaur v1 🦖 Dinozaur v2 ✅ Aplikacje To-Do List 🎨 Kreatywne wolne strony 🎯 FSACB - Ostateczny pokaz 🌍 Benchmark tłumaczeń
Modele
🏆 Top 10 modeli 🆓 Darmowe modele 📋 Wszystkie modele ⚙️ Kilo Code
Zasoby
💬 Biblioteka promptów 📖 Słownik AI 🔗 Przydatne linki 🔌 API i routery AI
advanced

Organizational Hierarchy Traversal

#sql #database #logic #querying

Write a complex recursive SQL query for a corporate structure.

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.