简体   繁体   English

Access DB中的分组/求和查询

[英]Grouping/Summing query in Access DB

I have a table with multiple fields that I am grabbing information from (8 to be specific) but within this query I need to group on one field (ID's) and sum two other fields separately (Units, MV).我有一个包含多个字段的表,我从中获取信息(具体为 8 个),但在此查询中,我需要对一个字段(ID)进行分组,并分别对另外两个字段(单位、MV)求和。 I can pull all the information together in 2-3 queries but I want to know if i can pull/put everything together in one query.我可以在 2-3 个查询中将所有信息汇总在一起,但我想知道我是否可以将所有信息汇总到一个查询中。

The correct result would be a query that groups the results on the ID field only, has both Units and MV summed separately but also have the other fields I need too.正确的结果将是一个仅在 ID 字段上对结果进行分组的查询,将 Units 和 MV 分别求和,但也有我需要的其他字段。 I can get part of the results in one query if I only have the grouped ID field and summed Units and MV fields but if I add any other fields then the results are incorrect.如果我只有分组的 ID 字段和汇总的单位和 MV 字段,我可以在一个查询中获得部分结果,但如果我添加任何其他字段,则结果不正确。 Any assistance would be appreciated.任何援助将不胜感激。

I ended up messing around with using DISTINCT within the SQL portion of access and finally got the results.我最终在访问的 SQL 部分中使用 DISTINCT 并最终得到了结果。 Thank you for all your help!谢谢你的帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM