To obtain a random integer R in the range [cci lang='sql' line_numbers='false']i <= R < j[/cci], use the expression [cci lang='sql' line_numbers='false']FLOOR(i + RAND() * (j – i))[/cci]. For example, to obtain a random integer in the range the range [cci lang='sql' line_numbers='false']7 <= R < 12[/cci], you could use the following statement:
[cci lang='sql' line_numbers='true']SELECT FLOOR(7 + (RAND() * 5));[/cci]
No comments:
Post a Comment