查询 - 前5个记录 [英] Query - Top 5 Records

查看:75
本文介绍了查询 - 前5个记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一张桌子,上面有供应商列表,总花费以及他们适合的食谱。


我想要的一个查询按总支出返回前5个记录,但是当我从顶部值下拉框中选择前5个选项时,它会返回我在表格中输入的前5个记录。


有什么方法可以让我的查询根据总花费选择前5条记录吗?

解决方案





我有一张桌子,里面有供应商名单,总花费以及他们适合的食物。


我想要的一个查询按总支出返回前5个记录,但是当我从顶部值下拉框中选择前5个选项时,它会返回我在表格中输入的前5个记录。


有什么方法可以让我的查询根据总支出选择前5条记录?



在查询窗口中,每个字段下都有一个选项排序。在总花费下,将其更改为降序排序,这应该可以解决问题。

(如果要编辑SQL视图,则需要在最后添加(在...之前)分号):ORDER BY [Total_Spent] DESC)


希望这会有所帮助。


干杯。如此简单但如此有效


我在类似的路径上有一个问题......鉴于前面的场景,如果你想运行一个能够按状态拉出前5个值的查询,不仅仅是前5个整体价值。关于SQL语句会是什么样子的任何想法?任何帮助将非常感谢!谢谢!

Hi

I have a table which has a list of suppliers, total spend and what cateogry they fit under.

I want a query to return the top 5 records in terms of total spend, however when I select the top 5 option from the top values drop down box it returns the first 5 records I entered into the table.

Is there any way I can get the query to select the top 5 records in terms of total spend?

解决方案

Hi

I have a table which has a list of suppliers, total spend and what cateogry they fit under.

I want a query to return the top 5 records in terms of total spend, however when I select the top 5 option from the top values drop down box it returns the first 5 records I entered into the table.

Is there any way I can get the query to select the top 5 records in terms of total spend?

On the query window, there is an option under each field to "Sort". Under the total spent, change this to "Sort Descending", and this should do the trick.
(If you want to edit the SQL view, you need to add at the end (just before the semi-colon): ORDER BY [Total_Spent] DESC)

Hope this helps.


Cheers for that. So simple yet so effective


I have a question along a similar path...given the previous scenario, what if you wanted to run a query that would pull the top 5 values by state, not just the top 5 overall values. Any ideas on what that SQL statement would look like? Any help would be very appreciated! Thanks!


这篇关于查询 - 前5个记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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