w3resource

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. From the following table, write a SQL query to find those departments where more than ten employees work, who got a commission percentage. Return department id.

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)

Relational Algebra Expression:

Relational Algebra Expression: Display those departments where more than ten employees work who got a commission percentage.

Relational Algebra Tree:

Relational Algebra Tree: Display those departments where more than ten employees work who got a commission percentage.

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: From the following table, write a SQL query to find those departments where a manager can manage four or more employees. Return department_id.
Next: From the following table, write a SQL query to find those employees who have completed their previous jobs. Return employee ID, end_date.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



SQL: Tips of the Day

MySQL export schema without data

mysqldump -h yourhostnameorIP -u root -p --no-data dbname > schema.sql

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