1 つの方法は、ウィンドウ関数を使用することです。
select t.*
from (select t.*,
sum(case when protocol = 'UDP' then 1 else 0 end) over (partition by sourceIP) as num_udp,
sum(case when protocol = 'IGMP' then 1 else 0 end) over (partition by sourceIP) as num_igmp
from table t
) t
where num_udp > 0 and num_igmp > 0;
編集:
これらのプロトコルのみが必要な場合:
select t.*
from (select t.*,
sum(case when protocol = 'UDP' then 1 else 0 end) over (partition by sourceIP) as num_udp,
sum(case when protocol = 'IGMP' then 1 else 0 end) over (partition by sourceIP) as num_igmp,
sum(case when protocol not in ('UDP', 'IGMP') then 1 else 0 end) over (partition by sourceIP) as num_other
from table t
) t
where num_udp > 0 and num_igmp > 0 and num_other = 0;
プロトコルをフィルタリングするだけの場合は、where protocol in ('UDP', 'IGMP')
.