title: SQL query to find the greater duplicate row
body: <p>I've a table in a DB that looks like this:</p>
  
  <pre><code>TABLE `partecipanti` (
    `ID` int(11) NOT NULL,
    `Name` varchar(30) DEFAULT NULL,
    `Surname` varchar(30) DEFAULT NULL,
    `Score2` int(11) DEFAULT NULL,
    `Zero1` int(11) DEFAULT '0',
    `Zero2` int(11) DEFAULT '0',
    `Score1` int(10) NOT NULL DEFAULT '0'
  )
  </code></pre>
  
  <p>And a query that looks like this:</p>
  
  <pre><code>SELECT *,Score1 + Score2 as Total FROM partecipanti
  ORDER BY Total DESC,Score2 DESC,Zero2 DESC,Score1 DESC, Zero1 DESC; 
  </code></pre>
  
  <p>Now the thing I'd like to do is : when I've a duplicate record (same name and same surname while the other data including ID are differents) pick the row that has the higher score which is stored in the field <code>Total</code></p>
  
  <p>I was thinking about a nested query,in the first query I order the data and I group them with GROUP BY, then I select the higher element. Could anyone help me please? Thanks.</p>
  
  <p>EDIT:</p>
  
  <p>If I add the DISTINCT statement the query seems to work , is it ok? Thanks.</p>