'How to sum one column if other have different value? [closed]

I have a table

clientId |    cns | cpf | value
       1 |      1 |   1 |     1
       1 |   null |   1 |     1

I need to sum the value column and get the not null value on column cns like this:

clientId |    cns | cpf | value
       1 |      1 |   1 |     2

The id field is not a primary key, is a clientId of other table. The field cpf sometimes have a value, sometimes have null.

Any idea?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source