w3resource
SQL exercises

SQL SORTING and FILTERING on HR Database: Display those departments where more than ten employees work who got a commission percentage

SQL SORTING and FILTERING on HR Database: Exercise-31 with Solution

31. Write a query in SQL to display those departments where more than ten employees work who got a commission percentage.

Sample table : employees


Sample Solution:

SELECT department_id 
	FROM employees 
		WHERE commission_pct IS NOT NULL
			GROUP BY department_id 
				HAVING COUNT(commission_pct)>10;

Sample Output:

 department_id
---------------
            80
            50
(2 rows)

Practice Online


HR database model

Query Visualization:

Duration:

Query visualization of Display those departments where more than ten employees work who got a commission percentage - Duration

Rows:

Query visualization of Display those departments where more than ten employees work who got a commission percentage - Rows

Cost:

Query visualization of Display those departments where more than ten employees work who got a commission percentage - Cost

Contribute your code and comments through Disqus.

Previous: Write a query in SQL to display those departments where any manager is managing 4 or more employees.
Next: Write a query in SQL to display the employee ID and the date on which he ended his previous job.

What is the difficulty level of this exercise?



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