One way (perhaps crude) is to have a table of discrete probabilities and then pick the value based on that as well. If I want to generate something between 0 and 5:CREATE TABLE #tmp(Value INT, CumulativeProbability FLOAT);
INSERT INTO #tmp VALUES
(0,15.0),(1,20.0),(3,25),(4,26),(5,100);
SELECT MIN(VALUE) FROM #tmp WHERE CumulativeProbability >= 100*RAND()
DROP TABLE #tmp;
I am giving a 74% probability to 100 in this case, so most of the results would be (should be) 5.