-
leecode - 1350. Students With Invalid DepartmentsSQL 문제풀이 2022. 7. 8. 16:19
난이도 : Easy
Table: Departments
+---------------+---------+ | Column Name | Type | +---------------+---------+ | id | int | | name | varchar | +---------------+---------+ id is the primary key of this table. The table has information about the id of each department of a university.
Table: Students
+---------------+---------+ | Column Name | Type | +---------------+---------+ | id | int | | name | varchar | | department_id | int | +---------------+---------+ id is the primary key of this table. The table has information about the id of each student at a university and the id of the department he/she studies at.
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.
SELECT Students.id , Students.name FROM Students LEFT JOIN Departments ON Students.department_id = Departments.id WHERE Departments.id IS NULL
Accepted (99.06%)
'SQL 문제풀이' 카테고리의 다른 글
leecode - 626. Exchange Seats (0) 2022.07.08 leetcode - 1378. Replace Employee ID With The Unique Identifier (0) 2022.07.08 leecode - 1327. List the Products Ordered in a Period (0) 2022.07.08 (Again) leecode - 612. Shortest Distance in a Plane (0) 2022.07.06 leetcode - 608. Tree Node (0) 2022.07.06