q. how can i randomly sort 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 clause to sort the rows by the result from the newid function, as the following code shows: