add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
create table t (ID int, ID_House varchar(2), ID_Postman varchar(2));

insert into t select 1, 'H1','P1';
insert into t select 2, 'H1','P1';
insert into t select 3, 'H1','P2';
insert into t select 4, 'H1','P2';
insert into t select 5, 'H2','P1';
insert into t select 6, 'H3','P1';
insert into t select 7, 'H4','P3';
7 rows affected
with x as (
select id_house, id_postman, Count(*) over(partition by id_postman) pq
from t
where id_house in ('h1','h2','h3')
group by id_house,id_postman
)
select id_postman
from x
where pq=(select Count(distinct id_house) from x)
group by id_postman
id_postman
P1
with x as (
select id_house, id_postman, Count(*) over(partition by id_postman) pq
from t
where id_house in ('h1','h2','h4')
group by id_house,id_postman
)
select id_postman
from x
where pq=(select Count(distinct id_house) from x)
group by id_postman
id_postman