title: SQL Query MAX date and some fields from other table
body: <p>I have two tables, say A and B.</p>
  
  <p>Table : A<br></p>
  
  <pre><code>ID_Sender |  Date     
  ________________________
     1      | 11-13-2013
     1      | 11-12-2013
  
     2      | 11-12-2013
     2      | 11-11-2013
  
     3      | 11-13-2013
     4      | 11-11-2013
  </code></pre>
  
  <p>Table : B</p>
  
  <pre><code>    ID    |  Tags
  _______________________
  1         | Company A
  2         | Company A
  3         | Company C
  4         | Company D
  </code></pre>
  
  <p>result table:</p>
  
  <pre><code>Tags        |   Date
  ____________________________
  Company A   | 11-13-2013
  Company C   | 11-13-2013
  Company D   | 11-11-2013
  </code></pre>
  
  <p>I have already tried out this out <a href="https://stackoverflow.com/questions/3491329/group-by-with-maxdate">GROUP BY with MAX(DATE)</a> but failed with no luck, I did some inner joins and subqueries but failed to produce the output.</p>
  
  <p>Here is my code so far, and an image for the output attached. </p>
  
  <pre><code>SELECT E.Tags, D.[Date] FROM 
          (SELECT A.ID_Sender AS Sendah, MAX(A.[Date]) AS Datee
          FROM tblA A
          LEFT JOIN tblB B ON A.ID_Sender = B.ID
          GROUP BY A.ID_Sender) C
      INNER JOIN tblA D ON D.ID_Sender = C.Sendah AND D.[Date] = C.Datee
      INNER JOIN tblB E ON E.ID = D.ID_Sender
  </code></pre>
  
  <p>Any suggestions? I'm already pulling my hairs out !
  (maybe you guys can just give me some sql concepts that can be helpful, the answer is not that necessary cos I really really wanted to solve it on my own :) )</p>
  
  <p>Thanks! </p>