Member Avatar for සශික

hey, Previously I post my question. But it wasn't helped. So I tried own and make sum query.
It's not generate 0 value records. can anyone hep me ?

select
    loan.loan_id as 'Loan ID'
   ,loan.customer_name as 'Customer Name'
   ,loan.total_amount as 'Total Amount'
   ,ifnull(sum(settlement.amount),0) as 'Total Received'
   ,((loan.total_amount)-ifnull(sum(settlement.amount), 0))as 'Total Due'
from loan
inner join settlement  on  loan.loan_id =  settlement.loan_id
where loan.collector_name='kapoor'
group by loan.loan_id

By this code 2 records shows. But there is another loan collect by kapoor. And that loan still not collected ant payment. So I wanted to show Total Received = 0
Can help ?

Member Avatar for සශික

can't help ?

Member Avatar for සශික

help me?

Try
sum(ifnull(settlement.amount,0)) as 'Total Received'

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.