Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

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 Expression: Display the job title and average salary of employees.

Relational Algebra Tree:

Relational Algebra Tree: Display the job title and average salary of employees.

Practice SQLite Online


Model Database

Employee Model  Database - w3resource online SQLite practice

Structure of 'hr' database :

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?