SQL advanced -> Self Join between two instances of the same table

The mission is to calculate total salary of employees that work under supervision of specific manager. Manager id is stored in the field "ManagerNo". Every employee have this fields filled with id of some other employee, who is his/her manager. Only CEO john silver have NULL, because he stands on the top and nobody above him.
EmpNoEmpNameManagerNoSalary...
1john silverNULL210000...
2gret garbo165000...
3le chen280000...
...............

The query uses "Self Join" on two instances of Employees table :
SELECT a.EmpNo, TRIM(a.FirstName) & ' ' & TRIM(a.LastName) AS EmpName, SUM(b.Salary) AS TotalMoney
FROM Employees AS a INNER JOIN Employees AS b ON a.EmpNo=b.ManagerNo
GROUP BY a.EmpNo, TRIM(a.FirstName) & ' ' & TRIM(a.LastName)
ORDER BY SUM(b.Salary) DESC;

With following result:
EmpNoEmpNameTotalMoney
1john silver298000
8dona fiber215500
2gret garbo185000
5maggi forth141000
7anna poperplatz95000



sqlexamples.info