VIP 👤
🏠 Home
Benchmark
📊 Tutti i benchmark 🦖 Dinosauro v1 🦖 Dinosauro v2 ✅ App To-Do List 🎨 Pagine libere creative 🎯 FSACB - Ultimate Showcase 🌍 Benchmark traduzione
Modelli
🏆 Top 10 modelli 🆓 Modelli gratuiti 📋 Tutti i modelli ⚙️ Kilo Code
Risorse
💬 Libreria di prompt 📖 Glossario IA 🔗 Link utili 🔌 API e router IA
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.