Re: CASE - Mailing list pgsql-sql

From Tom Lane
Subject Re: CASE
Date
Msg-id 24789.1053389850@sss.pgh.pa.us
Whole thread Raw
In response to CASE  ("James Taylor" <jtx@hatesville.com>)
List pgsql-sql
"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 toCASE 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


pgsql-sql by date:

Previous
From: Manfred Koizar
Date:
Subject: Re: CASE
Next
From: "Dean Gibson (DB Administrator)"
Date:
Subject: Re: Testing castability of text to numeric