Re: insert only if conditions are met?

Поиск
Список
Период
Сортировка
От Chris Travers
Тема Re: insert only if conditions are met?
Дата
Msg-id 4315DD76.40504@metatrontech.com
обсуждение исходный текст
Ответ на Re: insert only if conditions are met?  (Henry Ortega <juandelacruz@gmail.com>)
Список 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

Вложения

В списке pgsql-sql по дате отправления:

Предыдущее
От: Tino Wildenhain
Дата:
Сообщение: Re: [GENERAL] How do I copy part of table from db1 to db2 (and
Следующее
От: "Akshay Mathur"
Дата:
Сообщение: Re: sql function: using set as argument