如何选择Access查询中的前10名? [英] How to select top 10 in Access query?

查看:561
本文介绍了如何选择Access查询中的前10名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Access数据库表有两列:名称和价格.我想查询一个查询,选择前10个最高价格.这该怎么做?谢谢.

My Access database table has 2 columns: name and price. I want to do a query that select the top 10 highest prices. How to do this? Thanks.

推荐答案

select top 10 Name, Price
from MyTable
order by Price desc

已更新:@Remou指出:

Updated: @Remou pointed out that:

"Access SQL选择匹配项,因此它将选择所有带有 最高价格,即使其中包含10条以上的记录也是如此.这 解决方法是按价格和唯一字段(列)进行订购."

"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)."

因此,如果您有唯一的产品代码列,请添加如下内容:

So, if you have a unique product code column, add like so:

select top 10 Name, Price
from MyTable
order by Price desc, UniqueProductCode desc

这篇关于如何选择Access查询中的前10名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆