Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SET @balance := 0;
- SET @high := 0;
- SELECT @high := GREATEST(@balance := @balance+credit-debit, @high) FROM mytable;
- SELECT @high;
- CREATE FUNCTION high_bal() RETURNS DECIMAL
- BEGIN
- SET @balance := 0;
- SET @high := 0;
- SELECT MAX(@high := GREATEST(@balance := @balance+debit_acc-credit_acc, @high))
- INTO @high
- FROM credit_acc where credit_used_acc=63395;
- RETURN @high;
- END$$
- BEGIN
- SET @balance := 0;
- SET @high := 0;
- SELECT @high := GREATEST(@balance := @balance+debit_acc-credit_acc, @high) FROM credit_acc where credit_used_acc=63395;
- RETURN @high;
- END$$
- print("code sample");
- DELIMITER ;
- select max(debit-credit) from yourtable
Add Comment
Please, Sign In to add comment