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 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 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?
- 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