I am using the below query which works fine if result of sum(otb.special_discount) is not null. but if the result is null the whole result of the sum query is returning null.
How I should correct this query that is for exampple sum(otb.total_charges) is 10000 and sum(otb.special_discount) is Null, I want the result to be 10000.
SELECT ott.test_name, (sum(otb.total_charges)- sum(otb.special_discount))as test_charges,
count(otb.id)count
from opd_test_bill otb,opd_test_type ott where otb.bill_type='p'
and otb.test_name=ott.id
and date between '2015-04-26 16:00:59' and '2015-04-27 06:00:00'
group by ott.test_name