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 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 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?
- 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