SQLite Exercise: Find the manager ID and the salary of the lowest-paid employee for that manager
Write a query to find the manager ID and the salary of the lowest-paid employee for that manager.
Sample table : employees
SQLite Code:
SELECT manager_id, MIN(salary)
FROM employees
WHERE manager_id IS NOT NULL
GROUP BY manager_id
ORDER BY MIN(salary) DESC;
Output:
manager_id MIN(salary) ---------- ----------- 24000 102 9000 205 8300 145 7000 146 7000 108 6900 147 6200 149 6200 148 6100 201 6000 100 5800 101 4400 103 4200 114 2500 123 2500 124 2500 120 2200 122 2200 121 2100
Relational Algebra Expression:
Relational Algebra Tree:
Practice SQLite Online
Model Database
Structure of 'hr' database :
Improve this sample solution and post your code through Disqus.
Previous: Write a query to get the difference between the highest and lowest salaries.
Next: Write a query to get the department ID and the total salary payable in each department.
What is the difficulty level of this exercise?
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- 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
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework