Skip to content
Advertisement

sql group by – curse and blessing

I have 3 tables for a meal calculation.

Now I like to find a meal by ingredient:

Which give me a list like:

Also I like to find meal by price like:

Which give me a list like:

Now let me build a query like

Which gives me a list like:

Because (i.price / i.minamount * r.quanitity) for this meal for meat is 1.99

Without “GROUP BY r.ingredientName” it returns only one values

But I need a list like:

Advertisement

Answer

Perhaps add an EXISTS to only get the meals with ‘meat’ in the recipe.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement