SQLite Exercise: List department number, name for all the departments in which there are no employees in the department
Write a query to list department number, name for all the departments in which there are no employees in the department.
Sample table : employees
Sample table : departments
SQLite Code:
SELECT * FROM departments
WHERE department_id
NOT IN (select department_id FROM employees);
Output:
department_id depart_name manager_id location_id ------------- ----------- ---------- ----------- 120 Treasury 1700 130 Corporate T 1700 140 Control And 1700 150 Shareholder 1700 160 Benefits 1700 170 Manufacturi 1700 180 Constructio 1700 190 Contracting 1700 200 Operations 1700 210 IT Support 1700 220 NOC 1700 230 IT Helpdesk 1700 240 Government 1700 250 Retail Sale 1700 260 Recruiting 1700 270 Payroll 1700
Practice SQLite Online
Model Database
Structure of 'hr' database :
Improve this sample solution and post your code through Disqus.
Previous: Write a query to select last 10 records from a table.
Next: Write a query to get 3 maximum salaries.
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