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:SELECT * FROM Northwind..Orders ORDER BY NEWID() SELECT TOP 10 * FROM Northwind..Orders ORDER BY NEWID() —SQL Server MVPs
FROM Northwind..Orders
ORDER BY NEWID() SELECT TOP 10 *
FROM Northwind..Orders
ORDER BY NEWID()
—SQL Server MVPs
不过看来没办法了,我在SQL里面试upto给的语句是完全可行的,但到Access里就不行。
没办法,老板要用Access。谢谢大家了。
另外问一下,如果用Fill(ds)把记录全部都取出来,然后再挑选的话会不会很慢啊