Re: [SQL] SELECT MAX returns wrong value

2007-12-13 Thread Tom Lane
Gavin Baumanis <[EMAIL PROTECTED]> writes: > If I perform the following SQL > SELECT MAX(column) FROM table WHERE expression > and there is no match, Postgres returns a record count of 1. > There is no value in max, it is NULL. This is the behavior required by the SQL standard. > Thus trying to

[SQL] SELECT MAX returns wrong value

2007-12-13 Thread Gavin Baumanis
Hi Everyone, Sorry if I am missing something obvious but I think I have found a bug. If I perform the following SQL SELECT MAX(column) FROM table WHERE expression and there is no match, Postgres returns a record count of 1. There is no value in max, it is NULL. Thus trying to perform some "oth

Re: [SQL] Query design assistance - getting daily totals

2007-12-13 Thread Steve Midgley
Hi, Rodrigo is exactly right in my opinion. To provide a little more info on this calendar or day dimension idea.. You can create, for example, a time table dimension which stores every day of every year as a unique record (for as far into the future as you need). You can then associate vari

Re: [SQL] Trigger definition . . . puzzled

2007-12-13 Thread Rolf A. de By
Ouch, that hurts! It suddenly dawns on me . . . Big difference on table that you specify and table where it actually takes effect. Confusing at first. Thanks a million, Tom. "Rolf A. de By" <[EMAIL PROTECTED]> writes: Yes, this is an inheritance set-up. But actually no: I am executing al

Re: [SQL] Trigger definition . . . puzzled

2007-12-13 Thread Tom Lane
"Rolf A. de By" <[EMAIL PROTECTED]> writes: > Yes, this is an inheritance set-up. But actually no: I am executing all > my data changes against the parent table, and want the trigger on that > parent table to fire for an insert on the parent table as it does. But > I also want the trigger to f

Re: [SQL] Trigger definition . . . puzzled

2007-12-13 Thread Rolf A. de By
Thanks Tom, Yes, this is an inheritance set-up. But actually no: I am executing all my data changes against the parent table, and want the trigger on that parent table to fire for an insert on the parent table as it does. But I also want the trigger to fire when an update on the parent table

Re: [SQL] Trigger definition . . . puzzled

2007-12-13 Thread Tom Lane
"Rolf A. de By" <[EMAIL PROTECTED]> writes: > Thanks for that. There is some misunderstanding here. For this example, > I had taken the sting out of my trigger function and turned it into a > much more concise no-op, with warnings. The actual code of my original > trigger function is irrelevan