I have this table: Employee
| emp_id | emp_name | salary | manager_id |
|---|---|---|---|
| 1 | emp_1 | 5000 | 7 |
| 2 | emp_2 | 3600 | 6 |
| 3 | emp_3 | 2500 | 7 |
| 4 | emp_4 | 4600 | 6 |
| 5 | emp_5 | 9000 | NULL |
| 6 | emp_6 | 7500 | 5 |
| 7 | emp_7 | 2300 | 6 |
I want to get the Average salary for the employees under manager
Here is an example of the result I want:
| emp_id | emp_name | AVG_Salary |
|---|---|---|
| 5 | emp_5 | 7500 |
| 6 | emp_6 | 3500 //which is (3600 + 4600 + 2300) / 3; |
| 7 | emp_7 | 3750 //which is (5000+ 2500) / 2; |
Can you please tell me how to figure out what I need to get the query please.