in your example you used SUM() to do the calculation but it didn't answer my question about calculating based on the previous sub select result out_standing and paid...
but in your example the case when field is null then 0 is useful for me.
I am guarding null from data entry but yes there can be null in these sub query.
Now I am not sure that you understand this.
Note that if you have nulls in gnd_total field, my query should return null for the whole sum, just like yours, the query I posted should return exactly the same resultset as the query from your post. Try both and compare the results.
If you want to replace nulls with zeros inside the sums, you should replace a.gnd_total with coalesce(a.gnd_total, 0) in all the places. The same in your original query, as well as in the one I posted.
For example, the first sum will then become:
SUM(CASE WHEN a.settlement_id IS NULL THEN 0 ELSE COALESCE(a.gnd_total, 0) END) AS out_standing,