简体   繁体   English

MS Access列和总和

[英]MS Access Columns and sums

So I'm stuck on a bit of a Doozy here. 因此,我在这里停留在Doozy上。 I'm trying to formulate a column in MS Access where it takes the rows with the same order number from Column A, and sums up those two same row value in column b and input into Column C 我正在尝试在MS Access中公式化一列,该列中的行与列A中的订单号相同,并求和列b中的两个相同行的值并输入到列C中

I'm relatively new to MS Access but familiar with SQL writing 我是MS Access的新手,但熟悉SQL编写

Perhaps that doesn't make sense but let me illustrate the columns for you 也许那没有道理,但让我为您说明各列

| Column A | Column B | Column C |

| Order 01 | $10      |   $45    |

| Order 01 | $15      |  $45     |

| Order 01 | $20      |   $45    |

| Order 02 | $300     |   $350   |

| Order 02 | $50      |  $350    |

Column C Is sum of all that is the same names in Column A Any help on how the SQL would be written or the design view in MS Access would be done would be great! C列是A列中所有相同名称的总和。有关如何编写SQL或MS Access中的设计视图的任何帮助将非常有用!

Is this what you are looking for? 这是你想要的?

select ColumnA, ColumnB,
       (select sum(ColumnB)
        from table1 as t2
        where t2.ColumnA = t.ColumnA
       ) as ColumnC
from table1 as t;

This calculates the third column for your result set. 这将为您的结果集计算第三列。

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

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