Answer the question
In order to leave comments, you need to log in
How to select a table row with a random chance?
There is a selection from the table:
id, chance
1, 20
2, 30,
3, 10
4, 5
chance - the chance of selecting this id.
How to do it right?
I have an idea, process in C#
Take all the data, calculate the amount of chance. Throw out a random number 0-sum. Then take one line at a time until we reach a line that is greater than the number. This is what you need
But you want something more cool.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question