Re: Sum of two rows - Mailing list pgsql-novice

From Manfred Koizar
Subject Re: Sum of two rows
Date
Msg-id p9mo6vobt99jslorlel868kgcjqrpe0glc@4ax.com
Whole thread Raw
In response to Sum of two rows  (Alexander Pucher <pucher@atlas.gis.univie.ac.at>)
List pgsql-novice
On Mon, 10 Mar 2003 11:02:33 +0100, Alexander Pucher
<pucher@atlas.gis.univie.ac.at> wrote:
>Let's pretend  I want to have a table with 3 columns.
>The first and second should each hold an integer value, the third should
>hold the sum of column1 + column2 as an integer.
>
>The idea behind this table should be that the sum is automatically
>updated, each time I change one of the values in either of the first two
>columns.

Either create your table without the third column and use a view
whenever you need the sum.

Or calculate the sum in a BEFORE INSERT / BEFORE UPDATE trigger.

Servus
 Manfred

pgsql-novice by date:

Previous
From: Alexander Pucher
Date:
Subject: Sum of two rows
Next
From: "cristi"
Date:
Subject: export from postgres into dbf