简体   繁体   中英

MS Access Columns and sums

So I'm stuck on a bit of a Doozy here. 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

I'm relatively new to MS Access but familiar with SQL writing

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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