Mysql from is followed by a subquery, which actually aggregates the results into a table
# case: query the salary scale of the average salary of each department
SELECT av.*, g.`grade _ level`from (SELECT AVG (salary) ag,department_id FROM employees GROUP BY department_id) avINNER JOIN job_grades gON av.ag BETWEEN g.`lowest _ sal`AND g.`highest _ sal`