MySQL Joins Exercises: Display the job title and average salary of employees
MySQL Joins: Exercise-10 with Solution
Write a query to display the job title and average salary of employees.
Sample table: employees
Sample table: jobs
Code:
SELECT job_title, AVG(salary)
FROM employees
NATURAL JOIN jobs
GROUP BY job_title;
Relational Algebra Expression:
Relational Algebra Tree:
Sample Output:
job_title AVG(salary) Accountant 7920 Accounting Manager 12000 Administration Assistant 4400 Administration Vice President 17000 Finance Manager 12000 Human Resources Representative 6500 Marketing Manager 13000 Marketing Representative 6000 President 24000 Programmer 5760 Public Accountant 8300 Public Relations Representative 10000 Purchasing Clerk 2780 Purchasing Manager 11000 Sales Manager 12200 Sales Representative 8350 Shipping Clerk 3215 Stock Clerk 2785 Stock Manager 7280
MySQL Code Editor:
Structure of 'hr' database :
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous:Write a query to display the department name, manager name, and city.
Next:Write a query to display job title, employee name, and the difference between salary of the employee and minimum salary for the job.
What is the difficulty level of this exercise?
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework