How to perform mathematical operation on field values in a table ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pugalenthi
    New Member
    • Jan 2007
    • 44

    How to perform mathematical operation on field values in a table ?

    I want to add values of few fields in a row and then divide it by a constant value and store the result in a new field on the same row. How can i do this ?.
  • JKing
    Recognized Expert Top Contributor
    • Jun 2007
    • 1206

    #2
    You could run an update query to store the result in the empty field.

    [code=sql]
    UPDATE yourTable
    SET result = (firstNumber + secondNumber) / constant
    [/code]

    This would store the the value of the sum of firstNumber and secondNumber divided by the constant in the field result of the table yourTable. The field result must already exist in yourTable.

    Though in most cases calculated fields are done through queries rather than stored as their own field.

    Jking

    Comment

    • pugalenthi
      New Member
      • Jan 2007
      • 44

      #3
      Originally posted by JKing
      You could run an update query to store the result in the empty field.

      [code=sql]
      UPDATE yourTable
      SET result = (firstNumber + secondNumber) / constant
      [/code]

      This would store the the value of the sum of firstNumber and secondNumber divided by the constant in the field result of the table yourTable. The field result must already exist in yourTable.

      Though in most cases calculated fields are done through queries rather than stored as their own field.

      Jking
      How can i add values in the fields of a table and store the result in a new field of the same table.

      Comment

      • JKing
        Recognized Expert Top Contributor
        • Jun 2007
        • 1206

        #4
        The above post demonstrates adding the field "firstNumbe r" and "secondNumb er" from the table "yourTable" and then stores the value in the field "result" in that very same table.

        Comment

        Working...