小组的前x名 [英] top x of group
问题描述
我想创建一个查询,该查询仅限于在另一个字段中具有相同数据的记录的前x(根据一个字段)。
例如,假设我想根据每个州的人口列出前5个城市。我有一个覆盖数千个美国城市的数据库,并且包含以下字段:State_Name,City_Name,Population。我使用这三个字段进行查询,并按State_Name按升序排序,按人口降序排序。我如何让它显示每个州5个人口最多的城市?
这可能很简单,但我感谢任何能提出答案的人。
我想创建一个查询,该查询仅限于具有相同数据的记录的前x(根据一个字段)在另一个领域。
例如,假设我想根据每个州的人口列出前5个城市。我有一个覆盖数千个美国城市的数据库,并且包含以下字段:State_Name,City_Name,Population。我使用这三个字段进行查询,并按State_Name按升序排序,按人口降序排序。如何让它显示每个州5个人口最多的城市?
这可能非常简单,但我感谢任何能够提出答案的人。
不知道这是否有效,但值得一试。
展开 | 选择 | Wrap | 行号
我想创建一个查询,该查询仅限于具有记录的前x(根据一个字段)另一个领域的相同数据。
例如,假设我想根据每个州的人口列出前5个城市。我有一个覆盖数千个美国城市的数据库,并且包含以下字段:State_Name,City_Name,Population。我使用这三个字段进行查询,并按State_Name按升序排序,按人口降序排序。如何让它显示每个州5个人口最多的城市?
这可能非常简单,但我感谢任何能够提出答案的人。
它不是那么简单,理论上不可能。
也许我夸大了这个案子,因为我经常发现人们可以来开箱即用的解决方案似乎打破了既定的规则,但我看不出任何可行的方式来实现这一点我很害怕。
< blockquote class =post_quotes>
它不是那么简单,理论上不可能。
也许我夸大了这个案子,因为我经常发现人们可以拿出''out out 盒子的解决方案似乎打破了既定的规则,但我看不出任何可行的方式来实现这一点我很害怕。
我想我可以通过VBA代码获得一个解决方案,最终结果(按州排名的5个最高城市)被写入表格。你认为这是值得的,还是浪费时间?我真的对你的意见感兴趣,因为我自己玩过它并且无法通过SQL Route找到解决方案。
I want to create a query that is limited to the top x (according to one field) of records that have the same data in another field.
For example, let''s say I want to list the top 5 cities by population in each state. I have a database that covers thousands of U.S. cities and has these fields: State_Name, City_Name, Population. I make a query with these 3 fields and sort it in ascending order by State_Name and in descending order by Population. How do I make it show _only_ the 5 highest-population cities of each state?
This is probably very simple, but I thank anyone who can suggest an answer.解决方案I want to create a query that is limited to the top x (according to one field) of records that have the same data in another field.
For example, let''s say I want to list the top 5 cities by population in each state. I have a database that covers thousands of U.S. cities and has these fields: State_Name, City_Name, Population. I make a query with these 3 fields and sort it in ascending order by State_Name and in descending order by Population. How do I make it show _only_ the 5 highest-population cities of each state?
This is probably very simple, but I thank anyone who can suggest an answer.Don''t know if this will work but it''s worth a try.
Expand|Select|Wrap|Line Numbers
I want to create a query that is limited to the top x (according to one field) of records that have the same data in another field.
For example, let''s say I want to list the top 5 cities by population in each state. I have a database that covers thousands of U.S. cities and has these fields: State_Name, City_Name, Population. I make a query with these 3 fields and sort it in ascending order by State_Name and in descending order by Population. How do I make it show _only_ the 5 highest-population cities of each state?
This is probably very simple, but I thank anyone who can suggest an answer.It''s not so much simple as theoretically impossible.
Maybe I overstate the case, as I often find that people can come up with ''out-of-the-box'' solutions that seem to break the established rules, but I can see no possible way of implementing this I''m afraid.
It''s not so much simple as theoretically impossible.
Maybe I overstate the case, as I often find that people can come up with ''out-of-the-box'' solutions that seem to break the established rules, but I can see no possible way of implementing this I''m afraid.I think I may be able to attain a solution via VBA code with the end results (5 highest cities population wise by State) being written to a Table. Do you think it is worth the effort, or just a waste of time? I''m truly interested in your opinion because I''ve played with it myself and could not arrive at a solution via the SQL Route.
这篇关于小组的前x名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文