w3resource

AdventureWorks Database: Find the departments that each have more than 15 employees

SQL Query - AdventureWorks: Exercise-94 with Solution

94. From the following tables write a SQL query to return the departments of a company that each have more than 15 employees.

Sample table: humanresources.employee


Click to view Full table

Sample Solution:

SELECT jobtitle,   
       COUNT(businessentityid) AS EmployeesInDesig  
FROM humanresources.employee e  
GROUP BY jobtitle  
HAVING COUNT(businessentityid) > 15;

Sample Output:

jobtitle                    |employeesindesig|
----------------------------+----------------+
Production Technician - WC30|              25|
Production Technician - WC60|              26|
Production Technician - WC50|              26|
Production Technician - WC20|              22|
Production Technician - WC10|              17|
Production Technician - WC40|              26|

SQL AdventureWorks Editor:

Practice Online


Contribute your code and comments through Disqus.

Previous: Return maximum, minimum, average salary and total employees for each department.
Next: Find the total products ordered in each specified orders.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Share this Tutorial / Exercise on : Facebook and Twitter

SQL: Tips of the Day

Convert Timestamp to date in MySQL Query:

DATE_FORMAT(FROM_UNIXTIME(`user.registration`), '%e %b %Y') AS 'date_formatted'

Database: MySQL

Ref : https://bit.ly/3EJPnMQ