Splice inquiries mysql from, is actually a collection of results into a table and

Case #: Query wage level of the average salary for each department

SELECT av.*,g.`grade_level`
FROM (

    SELECT AVG(salary) ag,department_id
    FROM employees
    GROUP BY department_id
) av
INNER JOIN job_grades g
ON av.ag BETWEEN g.`lowest_sal` AND g.`highest_sal`;

Guess you like

Origin blog.51cto.com/14437184/2438395