On Wed, 2005-08-31 at 14:54, Jim C. Nasby wrote: > SELECT sum(hours) FROM table WHERE emp_name = 'JSMITH' AND work_date = > '8-15-2005'::date will give you the hours. So... > > INSERT INTO table > SELECT blah > WHERE (SELECT sum(hours) FROM table WHERE emp_name = 'JSMITH' AND > work_date = > '8-15-2005'::date) != 8 > > Should do what you want.
I keep thinking a constraint it a better idea here. Or is this too complex to make it one easily. Either way, I'd make that last part: <8 instead of !=8, in case this uses floating point instead of int, and gets 8.0000000001 or what not in it. Or if someone manages to get it up to 9 or something. ---------------------------(end of broadcast)--------------------------- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly