Find Customer Referee
EasyLeetCodeSQL: SELECT & Filtering
Hint and exampleShowHide
A comparison with NULL is unknown rather than true, so add an explicit IS NULL check to keep the rows whose value is missing.
Example: students(name, mentor_id) — students not mentored by 4
name | mentor_id
Asha | 4
Ravi | NULL
Kiran | 2
SELECT name
FROM students
WHERE mentor_id <> 4 OR mentor_id IS NULL;
-- returns Ravi, Kiran (without IS NULL, Ravi is lost)
More in SQL: SELECT & Filtering
| # | Problem | Platform | Difficulty | Open | 1st1st Visit | 2nd2nd Visit | RevRevise |
|---|---|---|---|---|---|---|---|
| 1 | Recyclable and Low Fat Products | LeetCode | Easy | Solve Recyclable and Low Fat Products on LeetCode (opens in a new tab) | |||
| 2 | Big Countries | LeetCode | Easy | Solve Big Countries on LeetCode (opens in a new tab) | |||
| 3 | Article Views I | LeetCode | Easy | Solve Article Views I on LeetCode (opens in a new tab) | |||
| 4 | Not Boring Movies | LeetCode | Easy | Solve Not Boring Movies on LeetCode (opens in a new tab) | |||
| 5 | Find Customer Referee | LeetCode | Easy | Solve Find Customer Referee on LeetCode (opens in a new tab) |