Received: from charon.simplot.com (jrsmailhub.simplot.com [12.18.144.212]) by postgresql.org (8.11.3/8.11.4) with ESMTP id g03GKFm48922 for ; Thu, 3 Jan 2002 11:20:16 -0500 (EST) (envelope-from earlj@xanadu.simplot.com) Received: from xanadu.simplot.COM (151.113.0.132) by charon.simplot.com (MX V5.1-A AnGp) with SMTP; Thu, 3 Jan 2002 09:20:18 -0700 Received: from npa01zz001.simplot.com by xanadu.simplot.COM; (5.65v4.0/1.1.8.2/20Aug97-1116AM) id AA24125; Thu, 3 Jan 2002 09:20:18 -0700 Received: from earlj by npa01zz001.simplot.com with local (Exim 3.33 #1 (Debian)) id 16MAbJ-0005ar-00; Thu, 03 Jan 2002 09:20:17 -0700 To: "Karl Raven" CC: pgsql-sql@postgresql.org Subject: Re: change null to 0 in SQL script References: From: Jason Earl Date: 03 Jan 2002 09:20:17 -0700 In-Reply-To: Message-ID: <87itaj5rum.fsf@npa01zz001.simplot.com> Lines: 38 User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/21.1 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Archive-Number: 200201/19 X-Sequence-Number: 6110 I believe that you need the coalesce function. Here's the excerpt from the manual: COALESCE COALESCE(value[, ...]) The COALESCE function returns the first of its arguments that is not NULL. This is often useful to substitute a default value for NULL values when data is retrieved for display, for example: SELECT COALESCE(description, short_description, '(none)') ... Just write your query so that it looks something like this: SELECT coalesce(value_that_may_be_null, 0) FROM your_table; Jason "Karl Raven" writes: > I like to change a null value of a query to 0 in the SQL script. I > know how to do it in MS-SQL server and MS-Access but those commands > does not work in pg-sql. > > Anyone has any ideas? > > Thanks > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org