0

Write a query in SQL that uses a random number generator to create a variable integer to determine the amount of rows selected.

27th Jan 2017, 6:11 PM
Andre van Rensburg
Andre van Rensburg - avatar
2 ответов
0
---- Create the variables for the random number generation DECLARE @Random INT; DECLARE @Upper INT; DECLARE @Lower INT ---- This will create a random number between 1 and 999 SET @Lower = 1 ---- The lowest random number SET @Upper = 999 ---- The highest random number SELECT @Random = ROUND(((@Upper - @Lower -1) * RAND() + @Lower), 0) SELECT @Random
3rd Feb 2017, 1:11 PM
Akwin Lopez
Akwin Lopez - avatar
+ 1
Try using function rand(), which generates a random float number between 0.0 and 1.0 (1.0 not included), and the keyword LIMIT.
30th Jan 2017, 7:44 AM
Álvaro