X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EC567DAF8A for ; Wed, 26 Oct 2005 17:51:55 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 89394-04 for ; Wed, 26 Oct 2005 20:51:53 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id D7966DAF87 for ; Wed, 26 Oct 2005 17:51:53 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j9QKprfd011415; Wed, 26 Oct 2005 16:51:53 -0400 (EDT) To: Tyler Kellen Cc: pgsql-sql@postgresql.org Subject: Re: SUM not matching up on a JOIN In-reply-to: References: Comments: In-reply-to Tyler Kellen message dated "Wed, 26 Oct 2005 12:48:35 -0500" Date: Wed, 26 Oct 2005 16:51:53 -0400 Message-ID: <11414.1130359913@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] X-Spam-Level: X-Archive-Number: 200510/347 X-Sequence-Number: 23200 Tyler Kellen writes: > Why is my discount total different when I > left join the trans table to the totals? Are you sure that trans_item.trans_id is unique and accounts for all the existing values of trans.id? I don't see any unique index or foreign key constraints in your \d output, so the database isn't enforcing that condition for you ... regards, tom lane