SQL exercises on employee Database: Display the Grade, Number of employees, and maximum salary of each grade
SQL employee Database: Exercise-99 with Solution
[An editor is available at the bottom of the page to write and execute the scripts.]
99. Write a query in SQL to display the Grade, Number of employees, and maximum salary of each grade.
Sample table: employees
Sample table: salary_grade
SELECT s.grade, count(*), max(salary) FROM employees e, salary_grade s WHERE e.salary BETWEEN s.min_sal AND s.max_sal GROUP BY s.grade;
grade | count | max -------+-------+--------- 4 | 5 | 3100.00 1 | 3 | 1200.00 5 | 1 | 6000.00 3 | 2 | 1700.00 2 | 3 | 1400.00 (5 rows)
Sample Database: employee
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a query in SQL to list the department where at least two employees are working.
Next: Write a query in SQL to display the department name, grade, no. of employees where at least two employees are working as a SALESMAN.
What is the difficulty level of this exercise?
- New Content published on w3resource :
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework