# What I can get the due left of every person easily for the following table [image attached] ?

## Recommended Posts

I am trying to implement this for two days now but stuck with logics ! Please help.
What I can get the due left of every person easily for the following table [image attached] -
where
1.inc_due is the column to get total due for specific person like cust_id
2. inctype_id =11 is the type of dues paid for specific person (cust_id)
3. echo only due left by cust_id or person id

##### Share on other sites

So the result you're trying to get for those 5 rows of data is one row with cust_id=126 inc_due=0? Does the inc_amount matter?

Do you have a larger example?

##### Share on other sites

4 hours ago, requinix said:

So the result you're trying to get for those 5 rows of data is one row with cust_id=126 inc_due=0? Does the inc_amount matter?

Do you have a larger example?

Thank you. As you can see in the talbe "cust_id = 126" has paid 101,5000,1000 are the sell payment but the "inctype_id = 11" is the only due payment out of
inc_due = "500" + "500" =1000 -> so there should be due_left = 1000-100=900 . This is what I  want to calculate and display for each cust_id, if any cust_id does not have dues, it should display due_left = 0

##### Share on other sites

So you want the SUM(inc_due) minus the SUM(inc_amount) WHERE inctype_id=11?

##### Share on other sites

4 hours ago, requinix said:

So you want the SUM(inc_due) minus the SUM(inc_amount) WHERE inctype_id=11?

From the example data, that's what it looked like to me -- group by cust_id.

##### Share on other sites

This thread is more than a year old.

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

×   Pasted as rich text.   Restore formatting

Only 75 emoji are allowed.