title: firebird sql get corresponding field from max value
body: <p>I'm working on this report which is meant to return the last purchase date and last purchase quantity for a list of items.</p>
  
  <p>my basic sql is as follows:</p>
  
  <pre><code>select im.ItemName, max(prh.Receiptdate), prl.ReceiptQuantity/*which corresponds with max ReceiptDate*/
  from ItemMaster im
  left join PurchaseReceiptLines prl on prl.ItemName = im.ItemName
  left join PurchaseReceiptHeader prh on prh.ReceiptNum = prl.ReceiptNum
  group by im.ItemName
  </code></pre>
  
  <p>Does anyone have any pointers?</p>
  
  <p>Any help would be awesome</p>