title: sql sum round up
body: <p>Sql newbie here, Im stuck on a problem.</p>
  <p>I have a recipe ingredient table, and basically what I want to do is find the price of a recipe rounded up to whole ingredients.</p>
  <p>So I wrote this sql.</p>
  <pre><code>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
  </code></pre>
  <p>This is the interesting part.</p>
  <pre><code>sum (recipe_order_ingredient_quantity * ingredient_expected_cost)
  </code></pre>
  <p>This sql gets the right answer, as long as there are no half ingredients. If for example, you have
  0,25 packet of carrots, it will not round that up to 1 pack.</p>
  <p>So then I tried this.</p>
  <pre><code>sum (ingredient_planned_cost* ceiling (recipe_order_ingredient_quantity))
  </code></pre>
  <p>This did not work either. If there are two rows with half a carrot, that sql will sum each of these rows up to 1 carrot so it will count two whole carrots, instead of two halves (1).</p>
  <p>So basically I want my code to be able to understand that half + half is whole, and understand that you need a whole even if you only use a quarter.</p>