On 09/01/2012 02:07 PM, Thalis Kalfigkopoulos wrote:
Thanks all for the replies. Actually I had already tested that sum()
behaved correctly with respect to NULLs, meaning that it ignored them
(or treated them as 0, couldn't really tell). That's why I went ahead
sum()ing even though I knew NULLs w
On 2012-09-01, Chris Angelico wrote:
> On Sat, Sep 1, 2012 at 12:07 PM, David Johnston wrote:
>> These are not equivalent if some values of foo are not-null and you want the
>> sum of all non-null values while replacing any nulls with zero. So the
>> decision depends on what and why you are su
On Sat, Sep 1, 2012 at 6:19 AM, David Johnston wrote:
> On Aug 31, 2012, at 22:49, Tom Lane wrote:
>
>> David Johnston writes:
>>> On Aug 31, 2012, at 21:52, Tom Lane wrote:
David Johnston writes:
> That said you might want to try
> SUM(COALESCE(foo, 0))
>>
Actually I'd go wi
On Aug 31, 2012, at 22:49, Tom Lane wrote:
> David Johnston writes:
>> On Aug 31, 2012, at 21:52, Tom Lane wrote:
>>> David Johnston writes:
That said you might want to try
SUM(COALESCE(foo, 0))
>
>>> Actually I'd go with "COALESCE(SUM(foo), 0)" since that requires only
>>> one COAL
David Johnston writes:
> On Aug 31, 2012, at 21:52, Tom Lane wrote:
>> David Johnston writes:
>>> That said you might want to try
>>> SUM(COALESCE(foo, 0))
>> Actually I'd go with "COALESCE(SUM(foo), 0)" since that requires only
>> one COALESCE operation, not one per row.
> These are not equiv
On Sat, Sep 1, 2012 at 12:07 PM, David Johnston wrote:
> These are not equivalent if some values of foo are not-null and you want the
> sum of all non-null values while replacing any nulls with zero. So the
> decision depends on what and why you are summing.
It comes to the same result with SU
On Aug 31, 2012, at 21:52, Tom Lane wrote:
> David Johnston writes:
>> On Aug 31, 2012, at 19:14, Thalis Kalfigkopoulos wrote:
>>> This didn't work as expected (the NULL's persisted):
>>> ...CASE sum(foo) WHEN NULL THEN 0 ELSE sum(foo) END...
>
>> Guessing this form effectively evaluates to
>
David Johnston writes:
> On Aug 31, 2012, at 19:14, Thalis Kalfigkopoulos wrote:
>> This didn't work as expected (the NULL's persisted):
>> ...CASE sum(foo) WHEN NULL THEN 0 ELSE sum(foo) END...
> Guessing this form effectively evaluates to
> WHEN sum(foo) = NULL instead of IS NULL and thus the
On Aug 31, 2012, at 19:14, Thalis Kalfigkopoulos wrote:
> Hello all,
>
> I have a query that presents a sum() where in some records it's NULL
> because all members of the group are NULL.
> I decided I wanted to see a pretty 0 instead of NULL since it fits the
> logic of the app.
>
> This didn't
Hello all,
I have a query that presents a sum() where in some records it's NULL
because all members of the group are NULL.
I decided I wanted to see a pretty 0 instead of NULL since it fits the
logic of the app.
This didn't work as expected (the NULL's persisted):
...CASE sum(foo) WHEN NULL THEN
10 matches
Mail list logo