http://www.perlmonks.org?node_id=883166


in reply to Re: array of arrays calculations
in thread array of arrays calculations

SELECT h.e_id, h.cus, h.gd1-ifnull(t.gd1,0) as dif1, h.gd2-ifnull(t.gd2,0) as dif2 FROM tabla1 h left join tabla2 t on h.e_id = t.e_id and h.cus = t.cus;

This works