[英]Microsoft Access 2010 Max query on Count results
I need my access db i'm trying to use the Max function on the results of a Count function of a field i couldn't find any way of doing it - not through the user interface and not through SQL query. 我需要访问db我试图在字段的Count函数的结果上使用Max函数我找不到任何方法 - 不是通过用户界面而不是通过SQL查询。
This is my screen: 这是我的屏幕:
in the screen i have the count function working properly 在屏幕上我有计数功能正常工作
how can i run the Max function on the Count function results? 如何在Count函数结果上运行Max函数?
To "run the Max function on the Count function results" requires that you "roll up" your count results to a higher level of aggregation. 要“在计数功能结果上运行最大功能”,您需要将计数结果“汇总”到更高的聚合级别。 Save your existing query as HallCounts
and then create a new query that does something like 将现有查询保存为HallCounts
,然后创建一个类似的新查询
SELECT Country_Id, Max(CountOfHall_Id) AS MaxHallCount
FROM HallCounts
GROUP BY Country_Id;
Or, to select just the row(s) with the highest count, try something like this 或者,要仅选择计数最高的行,请尝试这样的操作
SELECT * FROM HallCounts
WHERE CountOfHall_ID = (SELECT MAX(CountOfHall_ID) FROM HallCounts);
I would use the TOP 1 SQL and DESC function. 我会使用TOP 1 SQL和DESC函数。 Or in the designer view it's "Return". 或者在设计师看来它是“回归”。
For example: 例如:
SELECT TOP 1 the_column_to_display
FROM the_table
ORDER BY Count(the_column_to_count) DESC;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.