Re: replace null with 0 in subselect ?

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Albrecht Berger <berger1517(at)gmx(dot)ch>
Cc: pgsql <pgsql-sql(at)postgresql(dot)org>
Subject: Re: replace null with 0 in subselect ?
Date: 2002-10-16 15:03:43
Message-ID: 20021016080309.A94982-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


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.

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Charles Hauser 2002-10-16 17:14:59 Use of reference table ('look-up-table') and FK constraint
Previous Message Tom Lane 2002-10-16 13:57:37 Re: set difference