pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Chris Travers <chris@metatrontech.com>
To: Henry Ortega <juandelacruz@gmail.com>
To: pgsql-sql <pgsql-sql@postgresql.org>
Subject: Re: insert only if conditions are met?
Date: Wed, 31 Aug 2005 09:40:22 -0700
Message-ID: <4315DD76.40504@metatrontech.com> (raw)
In-Reply-To: <2bffcc3305083108497ea6dcc6@mail.gmail.com>
References: <2bffcc33050831080942f806e1@mail.gmail.com>
	<20050831152534.GA18934@winnie.fuhr.org>
	<2bffcc3305083108487fb80cb2@mail.gmail.com>
	<2bffcc3305083108497ea6dcc6@mail.gmail.com>

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

Attachments:

chris.vcf (text/x-vcard, 125B) download begin:vcard fn:Chris Travers n:Travers;Chris email;internet:chris@metatrontech.com x-mozilla-html:FALSE version:2.1 end:vcard

view thread (14+ messages)  latest in thread

Message-ID: <4315DD76.40504@metatrontech.com>
Permalink:  ../4315DD76.40504@metatrontech.com/
Also on:    postgresql.org/message-id/4315DD76.40504@metatrontech.com

 · 

reply

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: chris@metatrontech.com, juandelacruz@gmail.com
  Subject: Re: insert only if conditions are met?
  In-Reply-To: <4315DD76.40504@metatrontech.com>

* 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