title: Order by per group (Query Builder)
body: <p>I have an user and a score table. Each user has multiple scores, for example:</p>
  
  <ul>
  <li>User1 has 3 scores: 45, 66, 98</li>
  <li>User2 has 2 scores: 75, 45</li>
  <li>User3 has 3 scores: 94, 66, 12</li>
  </ul>
  
  <p>Only the highest score for each user is relevant. What I want to achieve is to get the 10 users that have the highest score. This works with the following laravel query:</p>
  
  <pre><code>    $results = Score::orderBy('score', 'desc')
          -&gt;groupBy('user_id')
          -&gt;limit(10)
          -&gt;get()
  </code></pre>
  
  <p>The problem with this query is that it returns the top users, but not their highest score. It returns the first score in the group. So when I query over the given example, this will return:</p>
  
  <ul>
  <li>1: User1, 45</li>
  <li>2: User3, 94</li>
  <li>3: User2, 75</li>
  </ul>
  
  <p>How can I make sure that it returns the top users with their highest score? I tried to ->distinct('score') but that didn't work. </p>