title: Doctrine Query Base with grouping and latest record
body: <p>I have a table &quot;table_b&quot; that contain the following details<a href="https://i.stack.imgur.com/PhTcg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PhTcg.png" alt="Table Sample" /></a></p>
  
  <p>I would like to use doctrine to query an output with a specific condition. Currently I'm using the block below to query.</p>
  <pre><code>$table_a= $em-&gt;getRepository('table_a')-&gt;findOneBy(['id'=&gt;1]);
  foreach($table_a-&gt;table_b as $records){
      echo $records-&gt;name. &quot; : &quot; . $records-&gt;value;
  }
  </code></pre>
  <p>It will output the entire ArrayCollection. Is there a way to query the record base on latest 'Date Created', that is base on the grouping of column 'Foreign Key Table 2'.</p>