| From: | Chris Travers <chris(at)metatrontech(dot)com> |
|---|---|
| To: | Henry Ortega <juandelacruz(at)gmail(dot)com>, pgsql-sql <pgsql-sql(at)postgresql(dot)org> |
| Subject: | Re: insert only if conditions are met? |
| Date: | 2005-08-31 16:40:22 |
| Message-ID: | 4315DD76.40504@metatrontech.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
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
| Attachment | Content-Type | Size |
|---|---|---|
| chris.vcf | text/x-vcard | 127 bytes |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Ragnar Hafstað | 2005-08-31 16:44:58 | Re: insert only if conditions are met? |
| Previous Message | Henry Ortega | 2005-08-31 15:49:44 | Re: insert only if conditions are met? |