SQL Server is randomly sorted

zhaozj2021-02-16  46

Translation: SQL Server is randomly sorted

Randomly Sorting Query Results Query Result Random Sort Q. How can I Randomly Sort Query Results? Q: How can I randomly sort the query results? A. To randomly order rows, or to return x number of randomly chosen rows, you can use the RAND function inside the SELECT statement. But the RAND function is resolved only once for the entire query, so every row will get same value. You CAN use an order by the result from the newid function, as the backing code shows: A: The result record is random sort, or returned to the x-record record, can be implemented by using the RAND function in the SELECT statement . However, the RAND function only generates only once in the query, so each line will get the same value. The method can be sorted by using the NewID function in the Order By clause, the code is as follows: select * from northwind..roDERS ORDER BY newid () SELECT TOP 10 * from northwind..IrDERS Order by newid () author: Water

转载请注明原文地址:https://www.9cbs.com/read-28264.html

New Post(0)