5.5. Random Numbers

Random numbers used by programmers are usually pseudo-random numbers. That is, you have a function that takes a starting value, the seed, and each call to the function returns a new result. Most of the pseudo-random-number generators (usually just called RNG) return a floating-point fraction value between 0.00 and 0.9999... at whatever precision your SQL engine has. The choice of a seed to start the generator can be a constant or a constantly changing value like the system clock—given the same seed, it will always generate the same sequence.

This is obviously “mathematical heresy,” and there are RNGs that were later found not to pass statistical tests for randomness. However, a good RNG will have desirable properties, such ...

Get Joe Celko's Thinking in Sets: Auxiliary, Temporal, and Virtual Tables in SQL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.