VIP 👤
🏠 Home
Prestatietests
📊 Alle benchmarks 🦖 Dinosaur v1 🦖 Dinosaur v2 ✅ To-Do List applicaties 🎨 Creatieve vrije pagina's 🎯 FSACB - Ultieme showcase 🌍 Vertaalbenchmark
Modellen
🏆 Top 10 modellen 🆓 Gratis modellen 📋 Alle modellen ⚙️ Kilo Code
Bronnen
💬 Promptbibliotheek 📖 AI-woordenlijst 🔗 Nuttige links 🔌 AI-API's en routers
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.