如何随机选取n条记录或者对记录作随机排序
|
Q. 如何得到随机排序结果? A. 要得到随机排序的列,或者返回x条随机选择的列,你可以使用随机数。但是RAND函数在一个查询中只能返回一个结果。你可以在NOWID函数返回的列上做ORDER BY。请看示例: SELECT * SELECT TOP 10 * 这段话翻译得真是费劲,干脆不管原文,直接意译了。
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: SELECT * SELECT TOP 10 *
|
