title: Get Last Payment From A User in SQL
body: <p>I have this table</p>
  
  <p><a href="https://i.stack.imgur.com/aWW0E.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aWW0E.png" alt="enter image description here"></a></p>
  
  <p>I am trying to get the sum of principal + interest from the last transaction date. <strong>Column 4</strong>. is the last transaction performed - <strong>[No column name]</strong> is the transaction date</p>
  
  <p>What I have tried so far:</p>
  
  <pre><code>select sum(h.principal+h.interest) as amt_paid, MAX(h.trx_date)
  from Loanhist h WHERE h.ac_no = '$id' and h.trx_type='LP'
  GROUP BY principal, interest
  </code></pre>