开发者

SQL Server - Shuffle results randomly, but with a weight assigned to each record

开发者 https://www.devze.com 2023-03-17 14:26 出处:网络
I know that the normal way to shuffle results with SQL Server is to order by NEWID(), except I\'d like to instead use a weighted shuffle.

I know that the normal way to shuffle results with SQL Server is to order by NEWID(), except I'd like to instead use a weighted shuffle.

Each recor开发者_JS百科d in my table has an integer 'Importance' from 1 to 10. I'd like to order by RAND()*Importance, except SQL Server has RAND() return the same value for each record returned.

Any ideas please?


Take a look at SQL Server - Set based random numbers for some ideas

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号