Skip to content
Advertisement

Generating a list of random numbers, summing to a fixed amount using SQL

This question is about generating N random numbers whose sum is M(constant) using SQL.

For example we have a number M=9.754. We need 10 random numbers whose sum is 9.754.

It should be done in SQL Server environment.

Can anybody help me?

Advertisement

Answer

While the @Squirrel answer is interesting but numbers here is more random here is the code:

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement