Re: Sum of two rows

Поиск
Список
Период
Сортировка
От Manfred Koizar
Тема Re: Sum of two rows
Дата
Msg-id p9mo6vobt99jslorlel868kgcjqrpe0glc@4ax.com
обсуждение исходный текст
Ответ на Sum of two rows  (Alexander Pucher <pucher@atlas.gis.univie.ac.at>)
Список 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 по дате отправления:

Предыдущее
От: Alexander Pucher
Дата:
Сообщение: Sum of two rows
Следующее
От: "cristi"
Дата:
Сообщение: export from postgres into dbf