Re: Re: [HACKERS] Re: [SQL] MAX() of 0 records.
Robert B. Easter <reaster@comptechnews.com>
From: "Robert B. Easter" <reaster@comptechnews.com>
To: Tom Lane <tgl@sss.pgh.pa.us>, Chris Bitmead <chris@bitmead.com>
Cc: pgsql-bugs@postgresql.org, pgsql-hackers@postgresql.org
Date: 2000-07-07T16:53:27Z
Lists: pgsql-bugs, pgsql-hackers
On Fri, 07 Jul 2000, Tom Lane wrote: > Chris Bitmead <chris@bitmead.com> writes: > UPDATE foo > SET bar = (SELECT min(f1) FROM othertab > WHERE othertab.keycol = foo.keycol) > WHERE condition-determining-which-foo-rows-to-update > if you wanted to use an aggregate. This is pretty ugly, especially so If you use min(x) or max(x) frequently, isn't it best to make a trigger that intercepts x on insert and update, then check it and store it somewhere rather than scanning for it everytime? (not that this fixes any db problem thats being discussed here) -- Robert