Munna Donepudi Munna Donepudi - 3 years ago 67
SQL Question

Adding two columns and subtract from another

I have three columns in my database table, namely

owed
,
paid
and
writeoff
. I need to calculate the total outstanding after summing up
paid
and
writeoff
and subtract that from
owed
.

owed-(paid+writeoff)

Answer Source
select
  sum(t.owed - (t.paid + t.writeoff)) AS result
from 
  {your_table} t
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download