title: How to randomly pick rows while optimizing for the sum of a different measure
body: <p>I have to randomly pick rows from a table. I am doing this by using the <code>rand()</code> function inside the <code>qualifying row</code> statement. I want the random picks to collectively add up to 100 or close to 100 but cannot be greater than that (Qty field below). Below is an illustration of the input table</p>
  <pre><code>CID Qty
  ABC 5
  BCD 10
  CDE 50
  DEF 60
  EFG 40
  </code></pre>
  <p>In this particular case there is a convenient 60 &amp; 40 (from CDE and DEF). In their absence, I want the final results to be 50+40 (CDE + EFG)</p>
  <p>I am not looking for any kind of fit. The selection of the rows will be completely random and the only criteria is that the randomly selected rows add up as close to 100 as possible.</p>