Jeg fandt denne pæn lille algoritme i Quod Libet. Du kunne sikkert oversætte det til noget proceduremæssig SQL.
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