X-Original-To: pgsql-sql@postgresql.org Received: from localhost (unknown [64.117.224.193]) by developer.postgresql.org (Postfix) with ESMTP id DB631925544 for ; Mon, 19 May 2003 21:26:09 -0400 (EDT) Received: from developer.postgresql.org ([64.117.224.193]) by localhost (developer.postgresql.org [64.117.224.193:10024]) (amavisd-new) with ESMTP id 24498-05 for ; Mon, 19 May 2003 21:26:04 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by developer.postgresql.org (Postfix) with ESMTP id 19A639256E6 for ; Mon, 19 May 2003 20:17:31 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h4K0HUU6024790; Mon, 19 May 2003 20:17:30 -0400 (EDT) To: jtx@hatesville.com Cc: pgsql-sql@postgresql.org Subject: Re: CASE In-reply-to: <002201c31dd4$3f34c100$0000fea9@theplague> References: <002201c31dd4$3f34c100$0000fea9@theplague> Comments: In-reply-to "James Taylor" message dated "Sun, 18 May 2003 23:59:46 -0700" Date: Mon, 19 May 2003 20:17:30 -0400 Message-ID: <24789.1053389850@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new X-Archive-Number: 200305/376 X-Sequence-Number: 13541 "James Taylor" writes: > select case(sum(numbers)) when null then 0 else sum(numbers) end from > list_results; The reason the above doesn't work is that it expands to CASE WHEN sum(numbers) = null THEN ... which always fails ("= null" does not mean "is null"). Easier would be SELECT COALESCE(sum(numbers), 0) FROM list_results regards, tom lane