J'ai trouvé ce joli petit algorithme à Quod Libet. Vous pourriez probablement le traduire en SQL procédural.
function WeightedShuffle(list of items with weights):
max_score ← the sum of every item’s weight
choice ← random number in the range [0, max_score)
current ← 0
for each item (i, weight) in items:
current ← current + weight
if current ≥ choice or i is the last item:
return item i