title: SQL get latest record
body: <p>Pretty sure my question headline is terrible, but anyways I have a table called invoices and inside that table each invoice has an id and each id had a client id so clients will have multiple invoices. I am trying to get latest invoices remainingbalance, The code I wrote doesnt work, can anyone tell me what I am doing wrong?</p>
  
  <pre><code>SELECT c.clientid,
      c.clientname,
      c.billingdate,
      (SELECT remainingbalance 
       FROM invoice i 
       WHERE i.client = c.clientid) AS remaining
  FROM client c
  ORDER BY clientname
  </code></pre>