How can I randomly distribute the figure among rows?
563607Feb 27 2007 — edited Feb 28 2007I have a table ABC with column A having following values -
A
---
a1
a2
a3
a4
a5
a6
I have a fixed figure say for example, 175. I want to randomly generate a value against each of the row so that the sum of values would be 175.
So that I would have output like
A value
-- -------
a1 12
a2 13
a3 25
a4 100
a5 7
a6 18
or I could have something like
A value
-- -------
a1 5
a2 30
a3 4
a4 120
a5 11
a6 5
The constrain is that the sum of values should be 175 and the values should be generated randomly.
Can I do this with the single query?