You are grouping by employee_id. There is only one record for each employee_id in the table record. Doesn’t your avg have only one value? If you want the average salary of all employees, don’t groupb by
I have a problem understanding, average salary, what is average? If it is for employee_id, how can a person's salary be said to be average salary. Generally speaking, it is the salary of employees in a certain department whose average salary is greater than 8,000
select t.salary,t.employee_id,t1.avg_salary from employees t inner join (select department_id,avg(salary) avg_salary from employees group by department_id) t1 on t.department_id = t1.department and t1.avg_salary > 8000
Because you group by id, doesn’t there only be one salary under each ID?
Probably, you can give it a try
You are grouping by employee_id. There is only one record for each employee_id in the table record. Doesn’t your avg have only one value?
If you want the average salary of all employees, don’t groupb by
I have a problem understanding, average salary, what is average? If it is for employee_id, how can a person's salary be said to be average salary. Generally speaking, it is the salary of employees in a certain department whose average salary is greater than 8,000
select t.salary,t.employee_id,t1.avg_salary from employees t inner join (select department_id,avg(salary) avg_salary from employees group by department_id) t1 on t.department_id = t1.department and t1.avg_salary > 8000