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

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 select last 10 records from a table.
Next: Write a query to get 3 maximum salaries.

What is the difficulty level of this exercise?