Consider the following:
user_id weight
1 2
2 5
Is there a query that could select a user ID at random while using the weights to affect the odds of which ID gets chosen?
In other words, in such a scenario, is there a query that would look at this table and then choose 1 user ID at random from the following group:
[UserID_001, UserID_001, UserID_002, UserID_002, UserID_002, UserID_002, UserID_002]
So that UserID_002 has a 5/7 chance of being selected, and UserId_001 has a 2/7 chance of being selected.
This would be like each user having a number of tickets in a raffle, User_001 has 2 tickets, and User_002 has 5 tickets. Is it possible to do such a thing with an SQL query? Or do I need to use some other method?
Thanks in advance!