title: How to return rows with max value one column grouped by another column?
body: <p>this is data</p>
  
  <pre><code>id       code       status
  1          1          5
  2          1          6
  3          2          8
  4          2          9
  5          2          12
  6          3          15
  7          3          19
  8          3          13
  </code></pre>
  
  <p>what I need as a result is this:</p>
  
  <pre><code>id       code       status
  2          1          6
  5          2          12
  8          3          19
  </code></pre>
  
  <p>in other words I need al rows with max id in grouping by code.</p>
  
  <p>for example, for code 3, ids are 6, 7, 8 and I need row with 8. </p>
  
  <p>equivalent sql query would be </p>
  
  <pre><code>select * 
  from t inner join (select max(id) maxId from t group by code) t1
  on t.id = t1.maxId
  </code></pre>
  
  <p>Status column is irelevant, it's just an atribute.</p>
  
  <p>What is the linq query for something like this?</p>
  
  <p>Thanks in advance.</p>