w3resource
SQLite exercises

SQLite Exercise: Get the total salary, maximum, minimum, average salary of employees, for department ID 90 only

Write a query to get the total salary, maximum, minimum, average salary of employees (job ID wise), for department ID 90 only.

Sample table: employees


SQLite Code:

SELECT job_id, SUM(salary), AVG(salary), MAX(salary), MIN(salary)
FROM employees 
WHERE department_id = '90' 
GROUP BY job_id;

Output:

job_id      SUM(salary)  AVG(salary)  MAX(salary)  MIN(salary)
----------  -----------  -----------  -----------  -----------
AD_PRES     24000        24000.0      24000        24000
AD_VP       34000        17000.0      17000        17000

Sqlite Online Editor


Structure of 'hr' database :

hr database

Improve this sample solution and post your code through Disqus.

Previous: Write a query to get the average salary for each job ID excluding programmer.
Next: Write a query to get the job ID and maximum salary of the employees where maximum salary is greater than or equal to $4000.

What is the difficulty level of this exercise?



New Content: Composer: Dependency manager for PHP, R Programming