I have a question, it is possible to difference (mathematic operation) between two results?
Here is the code:
<?php
$row = $query->row();
echo "<b>Your total expenses:</b><br />". $row->TotalExpense;
?>
<?php
$row = $query2->row();
echo "<b>Your total incomes:</b><br />". $row->TotalIncome;
?>
<?php
$x = query2
$y = query1
echo $x - $y;
?>
If your start point is right. You kind of already had it.
<?php
$TotalExpense = $query->row()->TotalExpense;
$TotalIncome = $query2->row()->TotalIncome;
echo "<b>Your Balance:</b><br />". ($TotalIncome - $TotalExpense);
?>