By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,677 Members | 1,462 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,677 IT Pros & Developers. It's quick & easy.

Adding values in 2 columns in Access

P: 7

Here I need help from you all - I would like to add values in 2 columns and write them to a third column and get the avg value of the third column.

For Example:
Expand|Select|Wrap|Line Numbers
  1. ColumnA  ColumnB  ColumnC
  3. 1          5          6
  5. 2          6          8
  7. 3          7         10
  9. Avg                    8
Now I would like to run a query on a table - to add column A and Colum B, writing the sum to column C and finding avg of values in Column C.

Thanks in anticipation of your help.


Aug 28 '08 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 15k+
P: 31,754
There's really no point in writing ColumnC. Just display it instead.

Assuming a table :
Table Name = [tblMyTable]
Expand|Select|Wrap|Line Numbers
  1. ColumnA  Number
  2. ColumnB  Number
...then the following SQL provides your initial results set :
Expand|Select|Wrap|Line Numbers
  1. SELECT ColumnA,
  2.        ColumnB,
  3.        ColumnA+ColumnB AS ColumnC
  4. FROM tblMyTable
A query to show the average of ColumnC would need to be a separate query, and could be :
Expand|Select|Wrap|Line Numbers
  1. SELECT Avg(ColumnA+ColumnB) AS [Avg]
  2. FROM tblMyTable
Aug 28 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.