Help regarding RANDOM data selecting
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Use Mod() function with Random() function. For example Mod(Random(),100) will return a number between 0 and 99. For a 10% random sample, use Mod(Random(),100) < 10 in a constraint expression. The constraint expression could also include a restriction on @OUTROWNUM.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Krishna, since you require an equal number of records per key value to be selected, how is that number determined? Is it arbitrarily chosen at runtime or does it need to be calculated somehow? If calculated, what is the calculation?
Regards,
Regards,
- james wiles
All generalizations are false, including this one - Mark Twain.
All generalizations are false, including this one - Mark Twain.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Job parameter seems to be indicated then. For example:
Code: Select all
Mod(Random(),100) < 10 And @OUTROWNUM <= #jpMaxRowsPerNode#
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Since computers can only ever do pseudo-random, the answer depends totally on whether or not you use the same seed for the random number generator each time, or whether you use a different seed. A seed based on current date and time is fairly "random".
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Krishna,
Since you've marked this as resolved, would you share what your final solution was?
I was going to suggest using a column generator to gain access to the seed option with it's random generation. That can be parameterized as well. I think it's possible also within DB2.
Regards,
Since you've marked this as resolved, would you share what your final solution was?
I was going to suggest using a column generator to gain access to the seed option with it's random generation. That can be parameterized as well. I think it's possible also within DB2.
Regards,
- james wiles
All generalizations are false, including this one - Mark Twain.
All generalizations are false, including this one - Mark Twain.
There's not a method to do so within the transformer stage interface in Designer. You would need to write the logic in a transform outside of the Designer GUI (in Unix) to use the native Transform operator language and functions, which I believe includes seed functions for rand() and random().
I think how you've done it is sufficient to meet your needs and is easily supportable by others in the future.
Regards,
I think how you've done it is sufficient to meet your needs and is easily supportable by others in the future.
Regards,
- james wiles
All generalizations are false, including this one - Mark Twain.
All generalizations are false, including this one - Mark Twain.