By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
create table tableA(Name varchar(20), City varchar(20));
insert into tableA values
('Paulo','Rome')
,('Rudy','Singapore')
,('Ming','Singapore')
,('Takeshi','Tokyo')
,('Judy','Jakarta')
,('Yuki','Tokyo')
,('Steve','Singapore')
;
select * from tableA;
Name | City |
---|---|
Paulo | Rome |
Rudy | Singapore |
Ming | Singapore |
Takeshi | Tokyo |
Judy | Jakarta |
Yuki | Tokyo |
Steve | Singapore |
select case when count(*)=3 then 'true' else 'false' end res
from (
select *,
row_number() over (partition by city order by name) as rn
from tableA
where city in ('Berlin', 'Tokyo', 'Singapore')
) a
where rn = 1
res |
---|
false |
select case when count(*)=3 then 'true' else 'false' end res
from(
select distinct city
from tableA
where city in ('Berlin', 'Tokyo', 'Singapore')
) a
res |
---|
false |