Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How can I randomly distribute the figure among rows?

563607Feb 27 2007 — edited Feb 28 2007
I 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?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 28 2007
Added on Feb 27 2007
5 comments
348 views