Skip to content

Latest commit

 

History

History

584

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Given a table customer holding customers information and the referee.

+------+------+-----------+
| id   | name | referee_id|
+------+------+-----------+
|    1 | Will |      NULL |
|    2 | Jane |      NULL |
|    3 | Alex |         2 |
|    4 | Bill |      NULL |
|    5 | Zack |         1 |
|    6 | Mark |         2 |
+------+------+-----------+

Write a query to return the list of customers NOT referred by the person with id '2'.

For the sample data above, the result is:

+------+
| name |
+------+
| Will |
| Jane |
| Bill |
| Zack |
+------+

Solution 1.

# OJ: https://leetcode.com/problems/find-customer-referee/
# Author: github.com/lzl124631x
SELECT
    name
FROM
    customer
WHERE
    referee_id <> 2 OR referee_id IS NULL