SQL Interview Questions – Students With Invalid Departments

Spread the love

Problem Description –

Write an SQL query to find the id and the name of all students who are enrolled in departments that no longer exist.

Return the result table in any order.

The query result format is in the following example.

Difficulty Level – Easy

Problem Link – Invalid Department

Solution –

FROM Students
WHERE department_id NOT IN (SELECT id FROM Departments)

Rating: 1 out of 5.

Leave a Reply