M
M
Murad Kasp2020-05-26 19:21:10
Oracle
Murad Kasp, 2020-05-26 19:21:10

How to choose all the dishes consisting only of flour, eggs and sugar?

There are Dishes and a list of Ingredients for them (link N to N). How to choose all the dishes consisting only of flour, eggs and sugar?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Tsvetkov, 2020-05-26
@tsklab

Collect all the ingredients in one line and compare it with the list. LISTAGG .

SELECT dish_name FROM dish
  JOIN dish_ingredients …
  JOIN ingredients …
  GROUP BY dish_name
  HAVING ( LISTAGG( UPPER( ingredient_description ), ',' ) 
           WITHIN GROUP ( ORDER BY ingredient_description )) = 'МУКА,САХАР,ЯЙЦО'

you must have a list of words in alphabetical order

SELECT UPPER( LISTAGG( Name, ',' )) FROM
( SELECT 'мука' AS Name FROM dual
UNION
SELECT 'яйцо' FROM dual
UNION
SELECT 'сахар' FROM dual
ORDER BY 1 )

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question