You are right and wrong in the same time. :) I cannot give a predictable algorithm.
Here's why I say it is not correctly random:
The SELECT may extract more than one record with the same random key. If you take the first record (or according with any other rule) from the resulted cursor, than this second choice is not random. Let's say that SELECT returns records in the phisycal order when no other rule is in effect. This would mean that the records at the beginning of the table have more chances to be selected as the final winner. This says that the chance is not the same for all records, thus, my statement.
If you don't believe me, you can make tests with rand()*2 (it doesn't reduce the random character of the alghorithm). I bet it will balance to the records in the first half of the table.
I would say that if the number of records is much less than 1000000, the random choice is almost correct and it doesn't matter.
Vlad
>I disagree. Random does not necessarily mean unique. If you want to make sure you do not select the same person, then store the previous winners in a table for comparison. However, unless you can show me a predictable algorithm used by SELECT TOP 1 RAND()*1000000 etc. then it is random.
>
>George
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement