 <p>I think you need to add a row to your query like this:</p> <pre><code>SELECT MAX(sum_date) As sum_date, MAX(sum_accname) As sum_accname, MAX(sum_description) As sum_description, SUM(credit) As credit, SUM(debit) As debit, 1 As uNo FROM sum_balance WHERE sum_accname = {?acc_name} AND sum_date &lt; {?fromDate} UNION ALL SELECT sum_date, sum_accname, sum_description, credit, debit , 2 as uNo FROM sum_balance WHERE sum_accname = {?acc_name} AND sum_date &gt;= {?fromDate} AND sum_date &lt;= {?toDate} </code></pre> <p>With this query your first row, or the row that <code>uNo = 1</code> has the sum of older debits and credits.</p>