prohor Posted July 19, 2020 Share Posted July 19, 2020 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] - table link: https://ibb.co/xC53Cf4 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 Quote Link to comment Share on other sites More sharing options...
requinix Posted July 19, 2020 Share Posted July 19, 2020 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? Quote Link to comment Share on other sites More sharing options...
prohor Posted July 20, 2020 Author Share Posted July 20, 2020 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 Quote Link to comment Share on other sites More sharing options...
requinix Posted July 20, 2020 Share Posted July 20, 2020 So you want the SUM(inc_due) minus the SUM(inc_amount) WHERE inctype_id=11? Quote Link to comment Share on other sites More sharing options...
gizmola Posted July 20, 2020 Share Posted July 20, 2020 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.