Re: replace null with 0 in subselect ? - Mailing list pgsql-sql

From Stephan Szabo
Subject Re: replace null with 0 in subselect ?
Date
Msg-id 20021016080309.A94982-100000@megazone23.bigpanda.com
Whole thread Raw
In response to replace null with 0 in subselect ?  ("Albrecht Berger" <berger1517@gmx.ch>)
Responses Re: replace null with 0 in subselect ?
List 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.



pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: set difference
Next
From: Charles Hauser
Date:
Subject: Use of reference table ('look-up-table') and FK constraint