w3resource
SQL exercises

SQL Exercises: Find the names of departments where more than two employees are working

SQL JOINS: Exercise-29 with Solution

Write a query in SQL to find the names of departments where more than two employees are working.

Sample table:emp_department


Sample table: emp_details


Sample Solution:

SELECT emp_department.dpt_name
  FROM emp_details 
     INNER JOIN emp_department
       ON emp_dept =dpt_code
        GROUP BY emp_department.dpt_name
          HAVING COUNT(*) > 2;

Output:

Find the names of departments where more than two employees are working

Query Visualization:

Duration:

Query visualization of Find the names of departments where more than two employees are working - Duration

Rows:

Query visualization of Find the names of departments where more than two employees are working - Rows

Cost:

Query visualization of Find the names of departments where more than two employees are working - 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 first name and last name of employees working for departments with a budget more than Rs.50000.
Next: SQL SUBQUERIES Exercises Home

What is the difficulty level of this exercise?



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