title: SQL - Function to divide value among rows
body: <p>I normally don't do database programming so Im rusty on how to do certain stuff.  But I have an issue where I'm to take an item and if this item is in the same location but in different placements, divide the value of said item among the sum count between placements.</p>
  
  <p>here is my table structure:</p>
  
  <pre><code>LOCATION   PLACEMENT   VALUE  COUNT   ITEM
  25         12345        100    10      55555  &lt;----
  25         67890        100    20      55555  &lt;----
  25         11111        50      5      00000
  25         22222        75      5      11111
  </code></pre>
  
  <p>In other words <code>Item (55555)</code> is in 2 placements and the value of this item is <code>100</code></p>
  
  <p>The new value should be: <code>PLACEMENT 12345</code> will be (10/30) *100 = 33.3 and <code>PLACEMENT 67890</code> will be (20/30) * 100 = 66.7 </p>
  
  <p>Any idea how to do this in SQL or HQL? </p>