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?
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook