在 Microsoft Access 中从...中选择顶部(除 10 之外的所有)
有一个查询
SELECT TOP 10 ... FROM ... ORDER BY ...
假设我在 Access(实际上是 Jet)中 。 问题是:我怎样才能获得所有其他行...除了前 10 行之外的所有行?
Say I've got a query
SELECT TOP 10 ... FROM ... ORDER BY ...
in Access (well, really Jet). The question is: how can I get all the other rows... everything except the top 10?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
你不能做这样的事情吗?
它可能没有那么有效,但这是我能想到做这样的事情的唯一方法。 AFAIK SQL 中没有“BOTTOM”子句:)
Couldn't you do something like
it might not be that efficient but that's the only way off the top of my head I can think to do something like that. AFAIK there's no "BOTTOM" clause in SQL :)
请注意,您的排序顺序可能(如果您愿意)与您的排名顺序不同。
编辑:另一个想法:如果您已经知道共有多少行,您可以这样做(假设有 1000 行):
只需翻转排序,然后取剩余部分。
当然,如果你仍然想要按原始顺序排列结果,你就必须做一些愚蠢的事情,比如:
Note that your sorted order could, (if you wish) be different than your ranked order.
Edit: Another idea: If you already knew how many TOTAL rows were there, you could do (assuming 1000 rows):
Just flip the sort, and take the remaining portion.
Of course, if you still wanted the results in the original order, you'd have to do something silly like:
您可以创建一个排名字段(创建排名列的方法)并对其进行筛选:排名>10
You can create a rank field (Ways to Create Rank Column) and filter off of that: where rank >10
这通常最好在“客户端”完成,而不是在 DBMS 上完成,即将表的所有行提取到 ADO Classic 记录集中,然后使用 Filter 属性根据条件删除 10 行,或者排序然后设置然后跳过第一/最后 10 行,或设置适当的页面长度,然后跳过第一/最后一页等。它不仅取决于行数,还取决于目标应用程序,例如我知道如果这是数据源MS Access 报告然后过滤掉不需要的行可能会很麻烦。
This it something that is often better done on the 'client' side, rather on the DBMS i.e. fetch all the table's rows into an ADO Classic recordset then use the Filter property to remove the 10 rows based on criteria, or Sort then set then skip the first/last 10 rows, or set the page length as appropriate then skip the first/last page, etc. Not only does it depend on the number of rows but also the target application e.g. I know that if this is the data source for a MS Access report then filtering off the unwanted rows can be a lot of hassle.