pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: jtx@hatesville.com
Cc: pgsql-sql@postgresql.org
Subject: Re: CASE
Date: Mon, 19 May 2003 20:17:30 -0400
Message-ID: <24789.1053389850@sss.pgh.pa.us> (raw)
In-Reply-To: <002201c31dd4$3f34c100$0000fea9@theplague>
References: <002201c31dd4$3f34c100$0000fea9@theplague>

"James Taylor" <jtx@hatesville.com> 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



view thread (20+ messages)

Message-ID: <24789.1053389850@sss.pgh.pa.us>
Permalink:  ../24789.1053389850@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/24789.1053389850@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, jtx@hatesville.com
  Subject: Re: CASE
  In-Reply-To: <24789.1053389850@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox