w3resource
SQL exercises

SQL Exercises: Find the number of employees in each department along with the department code

SQL Aggregate Functions: Exercise-25 with Solution

Write a query in SQL to find the number of employees in each department along with the department code.

Sample table: emp_details


Sample Solution:

SELECT emp_dept, COUNT(*)
  FROM emp_details
  GROUP BY emp_dept;

Sample table: emp_details


Output:

SQL Join Exercise

Query Visualization:

Duration:

Query visualization of Find the number of employees in each department along with the department code - Duration

Rows:

Query visualization of Find the number of employees in each department along with the department code - Rows

Cost:

Query visualization of Find the number of employees in each department along with the department code - Cost

Practice Online


Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a query in SQL to find the sum of the allotment amount of all departments.
Next: SQL Formatting Output Exercises Home

What is the difficulty level of this exercise?



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