title: How to return multiple columns of the same row in T-SQL using GROUP BY
body: <p>I have a Transactions table that contains the following columns:
  MemberID,
  TransactionID,
  Date,
  MethodOfPayment,
  + a lot more columns</p>
  
  <p>The primary key consists of MemberID and TransactionID. I need a query that groups these rows by MemberID for the latest date. That's easy, but additionally I need the rest of the columns for the latest date, such as MethodOfPayment. I'm looking for the simplest way to accomplish this.</p>
  
  <p>I know this is one way I could do it, but the query gets really long if I have to include a subquery for every column I have. My gut tells me there has to be a better way.</p>
  
  <pre><code>SELECT
     MemberID,
     MAX(Date) AS Date,
     (
        SELECT TOP(1) MethodOfPayment
        FROM Transactions
        WHERE MemberID = t.MemberID
        ORDER BY Date DESC
     ) AS MethodOfPayment
  FROM Transactions t
  GROUP BY MemberID
  </code></pre>