From: Mihail Nasedkin <m.nasedkin.perm@mail.ru>
To: Muhyiddin A.M Hayat <middink@indo.net.id>
Cc: pgsql-sql@postgresql.org
Subject: Re: Debet-Credit-Balance Calculation
Date: Wed, 20 Apr 2005 08:28:58 +0600
Message-ID: <1412347250.20050420082858@mail.ru> (raw)
In-Reply-To: <001c01c544ff$bb94d650$1f00a8c0@middinks>
References: <001c01c544ff$bb94d650$1f00a8c0@middinks>
I think you forget FOREIGN KEY:
transactions.trx_type_id -> trx_type.id
MAMH> Dear All,
MAMH> I have problem to calculation
MAMH> balance from debet and credit.
MAMH> my transaction table:
...
MAMH> CREATE TABLE "public"."transactions" (
MAMH>
MAMH> "id" SERIAL,
MAMH> "trx_timestamptz" TIMESTAMP(0) WITH TIME ZONE DEFAULT
MAMH> ('now'::text)::timestamp(6) with time zone NOT NULL,
MAMH> "account"
MAMH> CHAR(16) NOT NULL,
MAMH> "trx_type_id" INTEGER NOT NULL,
MAMH>
MAMH> "amount" NUMERIC(15,2) DEFAULT 0 NOT NULL,
MAMH> "uid" INTEGER NOT NULL,
MAMH> CONSTRAINT "transactions_pkey" PRIMARY KEY("id")
MAMH> ) WITH
MAMH> OIDS;
...
MAMH> and transaction type :
...
MAMH> CREATE TABLE "public"."trx_type" (
MAMH> "id" SERIAL,
MAMH> "trx_name" VARCHAR(32),
MAMH> "t_type" CHAR(2),
MAMH>
MAMH> CONSTRAINT "trx_type_pkey" PRIMARY KEY("id"),
MAMH> CONSTRAINT
MAMH> "trx_typei_check0" CHECK ((t_type = 'CR'::bpchar) OR (t_type =
MAMH> 'DB'::bpchar))
MAMH> ) WITH OIDS;
MAMH> ---------------------------------------------------------------------
MAMH> so, i'm using this query:
...
MAMH> ... query eat all my cpu process and take a long time ...
--
regards,
Mihail mailto:m.nasedkin.perm@mail.ru
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: m.nasedkin.perm@mail.ru, middink@indo.net.id
Subject: Re: Debet-Credit-Balance Calculation
In-Reply-To: <1412347250.20050420082858@mail.ru>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox