By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
create table customer (id int, name varchar(9), referee_id int)
insert into customer values(1, 'Will', null)
insert into customer values(2, 'Jane', null)
insert into customer values(3, 'Alex', 2)
insert into customer values(4, 'Bill', null)
insert into customer values(5, 'Zack', 1)
insert into customer values(6, 'Mark', 2)
SELECT name FROM customer WHERE COALESCE(referee_id,2) <> 2;
name |
---|
Zack |
SELECT name FROM customer WHERE referee_id <> 2 or referee_id is null;
name |
---|
Will |
Jane |
Bill |
Zack |