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: Get the number of employees with the same job

Write a query to get the number of employees with the same job.

Sample table : employees


SQLite Code:

SELECT job_id, COUNT(*)
FROM employees
GROUP BY job_id;

Output:

job_id      COUNT(*)
----------  ---------
AC_ACCOUNT  1
AC_MGR      1
AD_ASST     1
AD_PRES     1
AD_VP       2
FI_ACCOUNT  5
FI_MGR      1
HR_REP      1
IT_PROG     5
MK_MAN      1
MK_REP      1
PR_REP      1
PU_CLERK    5
PU_MAN      1
SA_MAN      5
SA_REP      30
SH_CLERK    20
ST_CLERK    20
ST_MAN      5

Relational Algebra Expression:

Relational Algebra Expression: Get the number of employees with the same job.

Relational Algebra Tree:

Relational Algebra Tree: Get the number of employees with the same job.

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 get the highest, lowest, sum, and average salary of all employees.
Next: Write a query to get the difference between the highest and lowest salaries.

What is the difficulty level of this exercise?