SQLite Exercise: Display the job title and average salary of employees
Write a query to display the job title and average salary of employees.
Sample table : employees
SQLite Code:
SELECT job_title, AVG(salary)
FROM employees
NATURAL JOIN jobs
GROUP BY job_title;
Output:
job_title AVG(salary) ---------- ----------- Accountant 7920.0 Accounting Manager 12000.0 Administration Assistant 4400.0 Administration Vice President 17000.0 Finance Manager 12000.0 Human Resources Representative 6500.0 Marketing Manager 13000.0 Marketing Representative 6000.0 President 24000.0 Programmer 5760.0 Public Accountant 8300.0 Public Relations Representative 10000.0 Purchasing Clerk 2780.0 Purchasing Manager 11000.0 Sales Manager 12200.0 Sales Representative 8350.0 Shipping Clerk 3215.0 Stock Clerk 2785.0 Stock Manager 7280.0
Relational Algebra Expression:
Relational Algebra Tree:
Practice SQLite Online
Model Database
Structure of 'hr' database :
Improve this sample solution and post your code 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 the 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