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: