Faq/Base/027

    From The Document Foundation Wiki
    < Faq‎ | Base

    How to carry out calculations in a query

    It is very easy to perform calculations in queries to then retrieve and view the results.

    The following example illustrates a simple calculation in a query: the addition of values from two fields of one table and the multiplication of the sum by a value in another table.

    This approach will be applied to the calculation of the weighted scores of some students in a class.

    • The table fields:

    The table consists of a primary key and the fields "field1" and "field2".

    • The query

    Using the query wizard, you insert "field1" into the first column and then "field2" into the second column.

    To multiply the field values, put the following into the third column :

    "field1" * "field2"

    To divide the value in the first field by the value of the second field :

    "field1" / "field2"

    The calculations are made when the query is performed.