Creating a field that uses totals other fields?

From: Sloan Bowman <smileyq(at)nashlinux(dot)com>
To: pgsql-sql <pgsql-sql(at)postgresql(dot)org>
Subject: Creating a field that uses totals other fields?
Date: 2002-09-18 16:26:26
Message-ID: 5.1.1.6.2.20020918111926.00a82058@mail.nashlinux.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Ewan Grantham 2002-09-18 18:45:27 TSQL2 (Temporal SQL) support for Postgres
Previous Message david williams 2002-09-18 11:23:19 Re: Returning a reference to a cursor from a function