select
d.dish_name
from
(
select
di.dish_id,
LISTAGG(di.ingredient_id, ',') WITHIN GROUP (
order by
di.ingredient_id
) lst
from
dish_ingredients di
group by
di.dish_id
) foo,
dish d
where
foo.lst = (
select
LISTAGG(id, ',') WITHIN GROUP (
ORDER BY
id
)
from
ingredients ing
where
upper(ing.ingredient_description) in ('МУКА', 'САХАР', 'ЯЙЦО')
)
and d.id = foo.dish_id
having
count(ds.ingredient_id) = 3
select
dh.dish_name
from
dish_ingredients ds,
ingredients ing,
dish dh
where
ds.dish_id in (
select
ds.dish_id
from
dish_ingredients ds
group by
ds.dish_id
having
count(ds.ingredient_id) = 3
)
and upper(ing.ingredient_description) in ('МУКА', 'САХАР', 'ЯЙЦО')
and ds.ingredient_id = ing.id
and ds.dish_id = dh.id
group by dh.dish_name