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: Display the department name, manager name, and city

Write a query to display the department name, manager name, and city.

Sample table : employees


Sample table : departments


Sample table : locations


SQLite Code:

SELECT d.depart_name, e.first_name, l.city 
FROM departments d 
JOIN employees e 
ON (d.manager_id = e.employee_id) 
JOIN locations l USING (location_id);

Output:

depart_name     first_name  city
--------------  ----------  ----------
Administration  Jennifer    Seattle
Marketing       Michael     Toronto
Purchasing      Den         Seattle
Human Resource  Susan       London
Shipping        Adam        South San
IT              Alexander   Southlake
Public Relatio  Hermann     Munich
Sales           John        Oxford
Executive       Steven      Seattle
Finance         Nancy       Seattle
Accounting      Shelley     Seattle

Relational Algebra Expression:

Relational Algebra Expression: Display the department name, manager name, and city.

Relational Algebra Tree:

Relational Algebra Tree: Display the department name, manager name, and city.

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 display the department ID, department name, and manager first name.
Next: Write a query to display the job title and average salary of employees.

What is the difficulty level of this exercise?