I have table with columns (Employee, Manager, Salary). Need to calculate
aggregate salary for all employees corresponding to top-level managers in
one SQL. For example
Input table is :
Emp Manager Salary
A T 10
B A 11
C F 13
D B 5
Result should be :
Top-Lvl Manager Salary(agg)
T 26
F 13
Manager-Employee layering can go multiple levels.
类似问题一般都用用jdbc query出来然后用java解决核心逻辑
但是如果硬用mysql query该如何呢