My very simple solution would be to randomly pick a number from a predefined range where each each database entry would correspond to a subset of the range.
For example
Entry 1 = 1-80
Entty 2 = 81-99
Entry 3 = 99-100
then just randomly pick a number b/w 1-100 and then look-up the appropriate entry in the table above.