The standard states that any operation involving NULL will yield NULL. As NULL is not zero - it is
unavailable data. So if you deliberatelly want to treat NULL as zero in a special case, you have to do it manually. The simplest approach is using
COALESCE(expression, 0)
.
In your case it will looke like this one:
COALESCE(c.total,0)-COALESCE(p.reciveamt,0)