Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3B1E84765C1 for ; Wed, 16 Oct 2002 11:03:43 -0400 (EDT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id BA7444764D0 for ; Wed, 16 Oct 2002 11:03:42 -0400 (EDT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id C091BD602; Wed, 16 Oct 2002 08:03:43 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id A816E5C02; Wed, 16 Oct 2002 08:03:43 -0700 (PDT) Date: Wed, 16 Oct 2002 08:03:43 -0700 (PDT) From: Stephan Szabo To: Albrecht Berger Cc: pgsql Subject: Re: replace null with 0 in subselect ? In-Reply-To: <05f001c274fb$e8a5aba0$a07ba8c0@wxp> Message-ID: <20021016080309.A94982-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200210/177 X-Sequence-Number: 9894 On Wed, 16 Oct 2002, Albrecht Berger wrote: > Hello, > I have a statement like this : > > INSERT INTO tab1 (c1, c2, c3) VALUES (1,2, SELECT MAX(pos)+1 FROM tab2); Coalesce is your friend. :) Coalesce((select max(pos)+1 from tab2), 0) should work.