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 7D5A9D86E1 for ; Wed, 31 Aug 2005 13:40:29 -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 86855-09 for ; Wed, 31 Aug 2005 16:40:25 +0000 (GMT) Received: from mail.travelamericas.com (unknown [206.130.134.147]) by svr1.postgresql.org (Postfix) with SMTP id 041F5D86DB for ; Wed, 31 Aug 2005 13:40:23 -0300 (ADT) Received: (qmail 19190 invoked from network); 31 Aug 2005 16:40:24 -0000 Received: from unknown (HELO ?10.0.0.253?) (10.0.0.253) by verkiel.travelamericas.com with SMTP; 31 Aug 2005 16:40:24 -0000 Message-ID: <4315DD76.40504@metatrontech.com> Date: Wed, 31 Aug 2005 09:40:22 -0700 From: Chris Travers User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Henry Ortega , pgsql-sql Subject: Re: insert only if conditions are met? References: <2bffcc33050831080942f806e1@mail.gmail.com> <20050831152534.GA18934@winnie.fuhr.org> <2bffcc3305083108487fb80cb2@mail.gmail.com> <2bffcc3305083108497ea6dcc6@mail.gmail.com> In-Reply-To: <2bffcc3305083108497ea6dcc6@mail.gmail.com> Content-Type: multipart/mixed; boundary="------------070604020407090404000705" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.049 required=5 tests=[AWL=-0.001, FORGED_RCVD_HELO=0.05] X-Spam-Level: X-Archive-Number: 200509/50 X-Sequence-Number: 22597 This is a multi-part message in MIME format. --------------070604020407090404000705 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Henry Ortega wrote: > What I am trying to do is > * Insert a record for EMPLOYEE A to TABLE A > IF > the sum of the hours worked by EMPLOYEE A on TABLE A > is not equal to N > > Is this possible? Yes, but we will need to see your database schema to provide examples. A simple example might be INSERT INTO table_a SELECT firstname, lastname FROM table_b WHERE table_b IN (SELECT id FROM (SELECT id, sum(labor) as total_hours from table_c group by id) WHERE total_hours <> n); Best Wishes, Chris Travers Metatron Technology Consulting --------------070604020407090404000705 Content-Type: text/x-vcard; charset=utf-8; name="chris.vcf" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="chris.vcf" begin:vcard fn:Chris Travers n:Travers;Chris email;internet:chris@metatrontech.com x-mozilla-html:FALSE version:2.1 end:vcard --------------070604020407090404000705--