| From: | Manfred Koizar <mkoi-pg(at)aon(dot)at> |
|---|---|
| To: | Alexander Pucher <pucher(at)atlas(dot)gis(dot)univie(dot)ac(dot)at> |
| Cc: | pgsql-novice(at)postgresql(dot)org |
| Subject: | Re: Sum of two rows |
| Date: | 2003-03-10 09:25:27 |
| Message-ID: | p9mo6vobt99jslorlel868kgcjqrpe0glc@4ax.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-novice |
On Mon, 10 Mar 2003 11:02:33 +0100, Alexander Pucher
<pucher(at)atlas(dot)gis(dot)univie(dot)ac(dot)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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Alexander Pucher | 2003-03-10 10:02:33 | Sum of two rows |
| Previous Message | cristi | 2003-03-10 07:50:16 | select |