我的 Access 数据库表有 2 列:名称和价格。我想做一个查询,选择前 10 个最高价格。这个怎么做?谢谢。
最佳答案
select top 10 Name, Price
from MyTable
order by Price desc
更新:@Fionnuala 指出:
"Access SQL selects matches, so it will select all items with the same highest prices, even if this includes more than 10 records. The work-around is to order by price and a unique field (column)."
因此,如果您有唯一的产品代码列,请按如下方式添加:
select top 10 Name, Price
from MyTable
order by Price desc, UniqueProductCode desc
关于ms-access - Access查询中如何选择前10条?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9339079/