gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 21:33:32 24 4
gpt4 key购买 nike

我的 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 thesame highest prices, even if this includes more than 10 records. Thework-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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com