Discover sql generate random number between 1 and 100, include the articles, news, trends, analysis and practical advice about sql generate random number between 1 and 100 on alibabacloud.com
COPIED from:http://www.cnblogs.com/wuming/archive/2010/02/24/1672906.htmlFrom a table random 2 records, with select TOP * from Ywle ORDER by NEWID () the order by is generally sorted by a field, the return value of newid () is uniqueidentifier,
Obtain two random records FROM table A and use select top 10 * FROM ywle order by newid ()Order by is generally sorted by a certain field. The return value of newid () is uniqueidentifier. How does order by newid () randomly select records?Newid ()
Execute in Query Analyzer: Select rand (), you can see that the result is similar to a random decimal: 0.36361513486289558, a decimal like this is used in the actual application is not much, generally to take random numbers will take random integers.
Random numbers from 10 to 20SELECT Dbms_random.value (10,20) from dual;0-2 of the time integersSELECT ABS (MOD (dbms_random. random,3)) from DUAL;Random integers of 0-99SELECT ABS (MOD (dbms_random. random,100)) from DUAL;1. Randomly take records
Randomly fetch 2 records from a table, using select TOP * from Ywle ORDER by NEWID ()Order by is generally sorted by a field, the return value of newid () is uniqueidentifier, and the Order by NEWID () random selection record is performedNEWID ()
How ORACLE produces a random number: Dbms_random--1, Decimals (0 ~ 1)Select Dbms_random.value from dual;--2, decimals within the specified range (0 ~ 100)Select Dbms_random.value (0,100) from dual;--3, integer within the specified range (0 ~
Http://blog.sina.com.cn/s/blog_6a01140c0100wimi.html1. Randomly take records from the tableSELECT * FROM (SELECT * from staff ORDER by Dbms_random.random)Where RowNum To randomly fetch 3 records from the staff table2. Generate Random NumbersSELECT
1. Randomly take records from the tableSELECT * FROM (SELECT * from the staff Order by Dbms_random.random) where RowNum To randomly fetch 3 records from the staff table2. Generate Random NumbersSELECT Dbms_random. RANDOM from DUAL; produce
1. Randomly take records from the table SELECT * FROM (SELECT * from staff ORDER by Dbms_random.random)Where RowNum To randomly fetch 3 records from the staff table 2. Generate Random Numbers SELECT Dbms_random. RANDOM from DUAL;produce a random
Oracle Fetch random Number1. Randomly take records from the tableSELECT * FROM (SELECT * from the staff Order by Dbms_random.random) where RowNum To randomly fetch 3 records from the staff table2. Generate Random NumbersSELECT Dbms_random.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.