Skip to content
C

Employees Missing a Department

Easysql

The department column should really be NOT NULL, but the constraint was never added, so some rows slipped through with a missing department. Write a query returning id and name for every employee whose department is NULL, ordered by id.

sql
CREATE TABLE employees ( id INTEGER PRIMARY KEY, name TEXT NOT NULL, department TEXT, salary INTEGER );

Sample data:

sql
INSERT INTO employees (id, name, department, salary) VALUES (1, 'Asha', 'Engineering', 85000), (2, 'Rohan', NULL, 62000), (3, 'Neha', 'Sales', -500), (4, 'Vikram', 'Sales', 71000);

Input (stdin)

Output

Run your code to see output here...