Click here to Skip to main content
15,867,141 members

Comments by Anele 'Mashy' Mbanga (Top 6 by date)

Anele 'Mashy' Mbanga 6-May-15 7:03am View    
Great then.. Take care..
Anele 'Mashy' Mbanga 5-May-15 13:23pm View    
Wow, I have checked your example and if it works, then all is good. Remember, there are multiple records for your example that have different ids, or primary keys and to achieve your required output, your procedure above uses a loop for each record. Happy coding... and all the best
Anele 'Mashy' Mbanga 5-May-15 13:03pm View    
Hi again, I think you might have to consider using a trigger with your example within the database itself. I have also found out that you can also perhaps use a self join which I think was what you were trying to achieve. Whilst the example below is not what you want, perhaps its something you can explore for more details.

http://www.mysqltutorial.org/mysql-tips/mysql-compare-calculate-difference-successive-rows/

I will keep on looking for something for you.

Please also update your questions in the future to provide as much details as possible, as usually a process flow is much better to understand what one wants to achieve. Will keep you posted...
Anele 'Mashy' Mbanga 5-May-15 12:32pm View    
The balances calculated here are just for 1 account isnt it?
Anele 'Mashy' Mbanga 5-May-15 10:26am View    
Ohk, I get you. So the "last balance" from your formular above is the balance that is already there? If I understand this correctly, if for example we currently have a credit = 300, a debit = 50 and a balance = 600, you want your result to be 600 + 50 - 300 = 350 right?