Creating a field that uses totals other fields? - Mailing list pgsql-sql

From Sloan Bowman
Subject Creating a field that uses totals other fields?
Date
Msg-id 5.1.1.6.2.20020918111926.00a82058@mail.nashlinux.com
Whole thread Raw
List pgsql-sql
I am wanting to create a table that will sum up the total of an order and 
automatically put value in the specified field. An example of the table is 
below. Any ideas on how to do this.

CREATE TABLE  sales_info (
sales_id serial PRIMARY KEY,
prod_id int REFERENCES product (prod_id),
qty int,
unit_price numeric(4,2),
sub_total numeric(4,2),
tax numeric(4,2),
shipping numeric(4,2),
grand_total numeric(4,2));
The grand total is where I want the sum of the unit_price, tax, and 
shipping price entered automatically. Thanks for any help.


--Sloan



pgsql-sql by date:

Previous
From: "david williams"
Date:
Subject: Re: Returning a reference to a cursor from a function
Next
From: "Ewan Grantham"
Date:
Subject: TSQL2 (Temporal SQL) support for Postgres