w3resource
SQL exercises

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

SQL SUBQUERY: Exercise-38 with Solution

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

Sample table: emp_department


Sample table: emp_details


Sample Solution:

SELECT dpt_name FROM emp_department
  WHERE dpt_code IN
  (
    SELECT emp_dept
      FROM emp_details
      GROUP BY emp_dept
      HAVING COUNT(*) >2
  );

Output:

SQL Subqueries : Find the names of departments with more than two employees are working

Practice Online


Sample Database:

Model Database

Query Visualization:

Duration:

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

Rows:

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

Cost:

Query visualization of Find the names of departments with more than two employees are working - Cost

Contribute your code and comments through Disqus.

Previous: Write a query in SQL to find the departments which sanction amount is larger than the average sanction amount of all the departments.
Next: Write a query in SQL to find the first name and last name of employees working for departments which sanction amount is second lowest.

What is the difficulty level of this exercise?



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