Sum of null columns in SQL -
i have table a, b , c allow null values.
select a, b, c, + b + c 'sum' table if a, b , c values 10, null , null, sum column shows nothing in it.
is there way fix this, , display sum 10? other converting null s zeros?
you use sql coalesce uses value in column, or alternative value if column null
so
sum ( coalesce(a,0) + coalesce(b,0) + coalesce(c,0))
Comments
Post a Comment