英文:
Microsoft Access Group by
问题
有没有办法将我的姓名分组并按姓名汇总金额?请参考表格。姓名列来自多个表格。总共有约20个,但它们的值可能在任何列中重复。正如可以看到的,例如Michaela。我还有一个日期筛选器。如果我只查询一个列,那么姓名将被分组在一起并且金额将被累加,但我希望有所有列的一组。
提前感谢任何建议。
一个列可以正常工作。
英文:
is there a way to group my names together and add up the amount of money by name? See Table. Name columns... are from multiple tables. I have about 20 in total, but their value can be repeated in any column. As can be seen, for example, with Michaela. I also have a date filter there. If I make a query on only one column, the names are grouped together and the amounts are added up, but I would like to have a set of all columns.
Thanks in advance for any advice.
One column works fine
enter image description here
答案1
得分: 0
使用联合查询来收集数据:
选择 NameField1 作为 FullName,SumField1 作为 Amount 从 Table1
联合全部
选择 NameField2, SumField2 从 Table1
联合全部
选择 NameField1, SumField1 从 Table2
--- 等等。
现在,将这个查询作为源查询:
选择 FullName, Sum(Amount) 作为 TotalAmount
从 YourUnionQuery
按 FullName 分组
英文:
Use a union query to collect the data:
Select NameField1 As FullName, SumField1 As Amount From Table1
Union All
Select NameField2, SumField2 From Table1
Union All
Select NameField1, SumField1 From Table2
--- etc.
Now, use this query as source in yet a query:
Select FullName, Sum(Amount) As TotalAmount
From YourUnionQuery
Group By FullName
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论