On Mon, Sep 9, 2013 at 8:12 AM, Marc Mamin <M.Mamin@xxxxxxxxxxxx> wrote:
hi,
in addition to the others comments, you can also remove " ELSE 0 " from your query.
It will result in <NULL> values that are discarded by SUM.
For that matter, you could clean this up by using COUNT as your aggregate with a GROUP BY. See these two archives:
http://www.postgresql.org/message-id/CA+=1U=U-=OQv6P24PP7HrO3dvAf3mH-oELTT7+F7RWZsC1XkMQ@xxxxxxxxxxxxxx
http://www.postgresql.org/message-id/1377525567350-5768573.post@xxxxxxxxxxxxx
http://www.postgresql.org/message-id/CA+=1U=U-=OQv6P24PP7HrO3dvAf3mH-oELTT7+F7RWZsC1XkMQ@xxxxxxxxxxxxxx
http://www.postgresql.org/message-id/1377525567350-5768573.post@xxxxxxxxxxxxx