How do I do a calculation in a querie

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello! I am in desperate need of help! How do I do a calculation in a
query???? Please respond!
 
Alicat said:
Hello! I am in desperate need of help! How do I do a calculation in a
query???? Please respond!

Example:

If you build a query using Table1 which has two numeric fields Field1 and Field2
then...

SELECT Field1, Field2, Field1 + Field2 As SumOfFields
From Table1
 
What do you need to do?
There an example for a calculation
Field3: Field1 * Field2

In the SQL it will look like
Select Field1, Field2, (Field1 * Field2) as Field3 From TableName

It will help to understand what you are trying to do
 
I have made a Table of Depreciation and now I need to add three more columns
to the Depreciation one. There are no options for more than one field..... I
need to add Depreciation Expense, Accumulated Depreciation, and Book
Value...using the Straight Line Method Equation!!! PLEASE RESPOND!
 
Alicat said:
Hello! I am in desperate need of help! How do I do a calculation in a
query????


Depends on the calculation.

To calculate a value based on other values in the same
record, just create a calculated field using an appropriate
expression. E.g.

Amount: Price * Quantity

If you want to calulate a value base on values in every
record, then you need to use a Totals type query (View menu)
that group the records on at least one field and aggregates
(Count, Sum, Avg, etc) the values of another field.
 
I have made a Table of Depreciation and now I need to add three more columns
to the Depreciation one. There are no options for more than one field..... I
need to add Depreciation Expense, Accumulated Depreciation, and Book
Value...using the Straight Line Method Equation!!! PLEASE RESPOND!

Please don't yell at us. We're all volunteers here, donating our time
free of charge. Instant answers should not be expected.

There may be some volunteers expert in accounting but I'm not one. I
do not know how to calculate these (derived?) fields from data in your
table. I'm guessing that you might want to use Excel to do this if
you're in a great hurry - Excel is a spreadsheet with builtin
accounting functions; Access isn't.

You can enter up to 255 fields in a Query. If you have an expression
for Depreciation Expense, you can type:

Depreciation Expense: <your expression here>

in a vacant Field cell of the query grid. If you need some complex
function, you'll need to either link to a program library containing
the function, or write it in VBA as a custom user function.

John W. Vinson[MVP]
 
Hello! I am in desperate need of help! How do I do a calculation in a
query???? Please respond!

In a vacant Field cell in the query grid, type the desired name of the
calculated field and the expression to calculate it: e.g.

TotalCost: [MaterialCost] + [LaborCost] + [TaxRate] * [MaterialCost]

or whatever the expression might be.

John W. Vinson[MVP]
 
Back
Top