Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 40EEA9FB784 for ; Wed, 13 Jun 2007 10:33:44 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 28758-03 for ; Wed, 13 Jun 2007 10:33:32 -0300 (ADT) X-Greylist: delayed 00:09:12.475583 by SQLgrey-1.7.5 Received: from sccrmhc15.comcast.net (sccrmhc15.comcast.net [204.127.200.85]) by postgresql.org (Postfix) with ESMTP id 2967A9FB429 for ; Wed, 13 Jun 2007 10:33:38 -0300 (ADT) Received: from [192.168.1.6] (c-69-242-166-153.hsd1.mo.comcast.net[69.242.166.153]) by comcast.net (sccrmhc15) with ESMTP id <20070613131912015009br32e>; Wed, 13 Jun 2007 13:19:22 +0000 Message-ID: <466FEEC9.4050300@lake-lotawana.mo.us> Date: Wed, 13 Jun 2007 08:19:05 -0500 From: "A. R. Van Hook" User-Agent: Thunderbird 1.5.0.12 (X11/20070530) MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: join problem Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200706/88 X-Sequence-Number: 28578 I have join problem: "select i.ivid, v.eventdate, v.deposit, v.invdate, cai.db, sum(i.tax) as tax, sum(i.tax + i.rowtot) as totalP, (sum(i.tax + i.rowtot) - v.deposit) as balance from invoice v left outer join invoiceitems i on v.ivid = i.ivid where v.cusid = $cusid and v.cusid = cai.cusid group by i.ivid, v.eventdate, v.deposit, v.invdate, cai.db ERROR: missing FROM-clause entry for table "cai" If I add cai to the from clause "from invoice v, cai, I get ERROR: missing FROM-clause entry for table "cai" ERROR: invalid reference to FROM-clause entry for table "v" Where do I add the cai table reference??? thanks -- Arthur R. Van Hook Mayor - Retired The City of Lake Lotawana hook@lake-lotawana.mo.us hook@lota.us avanhook3@comcast.net (816) 578-4704 - Home (816) 564-0769 - Cell