<p>I have a table with a credit and debit column.</p>

<p>I need to get the highest balance out of that, and I think a stored procedure is the way to do it, but I have no idea how.</p>

<p>I need to start with the first row, add the debits, subtract the credits and store the value A.</p>

<p>Second row is A+debit-credit=B; A = max(A,B)
Repeat last step till the end.</p>

<p>Remember, I'm looking for the highest EVER, not the current, which would just be
sum(debit-credit)</p>

May
```
```
select max(debit-credit) from yourtable
```
```
work?
Try to test it.