ms-access - Access查询中如何选择前10条?

标签 ms-access

我的 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/

相关文章:

sql - 工作 Access SQL 查询的 T-SQL 迁移,在编写 IIF 的 CASE 替换时存在问题

database - Linq 到具有大数据库的实体

php - 使用 ODBC 连接 MS Access 时如何更改连接字符集?

android - 在 Android 应用程序中使用 Microsoft Access 文件

ms-access - 如何在 PostgreSQL/Access 组合中使用序列号/自动编号

vba - MS Access : eval() returns NULL when accessing . 列(x,y)属性

c# - SqlConnection 状态总是在执行时关闭

sql - MS Access-导出时导致别名 'Description' 循环引用

ms-access - Microsoft Office Access 数据库引擎找不到对象

sql - 选择带有日期条件的查询