部分组过滤器

Partial Group Filter

甲骨文 11g 我怎样才能获得 FURRRYSCALY 的所有 pet_owners 而只有 earthwormsslugs

with genus_def 
as (
select 'FURRY' as genus, 'Stays warm in winter'        as genus_desc from dual union all
select 'SLIMY' as genus, 'Great for practical jokes'   as genus_desc from dual union all
select 'SCALY' as genus, 'Best viewed with scuba mask' as genus_desc from dual 
) ,
favorite_pets as
(
select 'FERGUS' pet_owner, 'MEERKET' as pet_1, 'FURRY' as genus from dual union all
select 'LAMAR' pet_owner, 'POLECAT' as pet_1, 'FURRY' as genus from dual union all
select 'LAMAR' pet_owner, 'SEABASS' as pet_1, 'SCALY' as genus from dual union all
select 'SUZIE' pet_owner, 'CLOWNFISH' as pet_1, 'SCALY' as genus from dual union all
select 'LAMAR' pet_owner, 'EARTHWORM' as pet_1, 'SLIMY' as genus from dual union all
select 'HEIDI' pet_owner, 'SLUG'      as pet_1, 'SLIMY' as genus from dual union all
select 'BRONX' pet_owner, 'SALAMANDER' as pet_1, 'SLIMY' as genus from dual)
select f.pet_owner, 
       f.pet_1,
       f.genus
from favorite_pets f inner join genus_def g on f.genus = g.genus
where g.genus in ('FURRY','SCALY');  --GET ALL FURRY, SCALY and only EARTHWORMS and SLUGS

**DESIRED RESULTS**
FERGUS   MEERKET    FURRY
LAMAR    POLECAT    FURRY
LAMAR    SEABASS    SCALY
SUZIE    CLOWNFISH  SCALY
LAMAR    EARTHWORM  SLIMY
HEIDI    SLUG       SLIMY

您希望满足两个条件中的任何一个,所以您需要或:

WHERE g.genus IN ('FURRY', 'SCALY') 
   OR f.pet_1 IN ('EARTHWORM', 'SLUG')