title: How to make a SQL query for last transaction of every account?
body: <p>Say I have a table "transactions" that has columns "acct_id" "trans_date" and "trans_type" and I want to filter this table so that I have just the last transaction for each account.  Clearly I could do something like</p>
  
  <pre><code>SELECT acct_id, max(trans_date) as trans_date  
  FROM transactions GROUP BY acct_id;
  </code></pre>
  
  <p>but then I lose my trans_type.  I could then do a second SQL call with my list of dates and account id's and get my trans_type back but that feels very cludgy since it means either sending data back and forth to the sql server or it means creating a temporary table.</p>
  
  <p>Is there a way to do this with a single query, hopefully a generic method that would work with mysql, postgres, sql-server, and oracle.</p>