Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

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 Expression: Find the manager ID and the salary of the lowest-paid employee for that manager.

Relational Algebra Tree:

Relational Algebra Tree: Find the manager ID and the salary of the lowest-paid employee for that manager.

Practice SQLite Online


Model Database

Employee Model  Database - w3resource online SQLite practice

Structure of 'hr' database :

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?