I'd really appreciate your help.
The situation is I have these two tables:
Table 1: debits. Example:
    date       item   value_debits
    2012-08-01 item1  10
    2012-08-03 item2  15
Table 2: credits. Example:
    date       item   value_credits
    2012-07-31 item3  20
    2012-08-02 item4  30  
Desired result:
    date       item   value  balance
    2012-07-31 item3  20     20
    2012-08-01 item1  (10)   10
    2012-08-02 item4  30     40
    2012-08-03 item3  (15)   25
I can easily calculate cumulative values for each of the tables separately:
set @cumulative :=0;
select date, item, value_debits, @cumulative := @cumulative + value_debits AS "Cumulated" 
from debits
order by date DESC
It's not too difficult to union and order by date these two tables to get this:
    date       item   value
    2012-07-31 item3  20
    2012-08-01 item1  10
    2012-08-02 item4  30
    2012-08-03 item3  15
But how to get to the desired result is beyond me.
Thanks in advance!