Jump to content


  • Posts

  • Joined

  • Last visited

Hermii's Achievements


Newbie (1/7)



  1. Hermii

    Help me

    Sql newbie here, Im stuck on a problem. I have a recipe ingredient table, and I want to calculate the price for a whole recipe rounded up to whole ingredient units. Every recipe has one row per ingredient and every ingredient has a price. So I this sql. select recipe_id_label, recipe_name, variation_name, portion_size, menu_id, variation_name, sum (recipe_order_ingredient_quantity * ingredient_expected_cost) from mb.weekly_menus_recipes_ingredients where recipe_id_label = '30943' and portion_size = '2' group by recipe_id_label, recipe_name, variation_name, portion_size, menu_id, variation_name it works as long as there are only whole ingredients in the recipe. But if one ingredient has for example 0,25 packet of carrots, it gets the wrong result. Remember I want whole units. So now I tried this sum (ingredient_planned_cost* ceiling (recipe_order_ingredient_quantity)) Still doesnt work, because if there are two halfs of the same ingredient it will sum those to two units. I want to round up the summed quantity, not every row by itself. And that's where Im stuck.
  • Create New...