title: SQL - How can I get the average employee salary for each department?
body: <p>This is the UML for the tables:  <a href="https://dev.mysql.com/doc/employee/en/sakila-structure.html" rel="nofollow noreferrer">https://dev.mysql.com/doc/employee/en/sakila-structure.html</a></p>
  
  <p><a href="https://i.stack.imgur.com/QW99N.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QW99N.png" alt="enter image description here"></a></p>
  
  <p>This my attempt: </p>
  
  <hr>
  
  <pre><code>SELECT
      CONCAT(employees.first_name, ' ', employees.last_name) AS 'EmployeeName',
      salaries.emp_no AS 'Employee Number',
      departments.dept_no AS 'Department Number',
      departments.dept_name AS 'Department name',
      AVG(salaries.salary) AS 'Average salary'
  FROM salaries
  INNER JOIN dept_emp
      ON salaries.emp_no = dept_emp.emp_no
  INNER JOIN employees
      ON salaries.emp_no = employees.emp_no
  INNER JOIN departments
      ON dept_emp.dept_no = departments.dept_no
  GROUP BY    salaries.emp_no,
              dept_emp.dept_no
  </code></pre>
  
  <hr>
  
  <p>I just get the average employee salary for all departments a person worked in.
  My desired result must group by each employee for each department.  Any help is appreciated.</p>