title: Find Duplicates using Rank Over Partition
body: <p>The following SQL works in identifying unique phones when there is a disparity in LastDate.
  But if duplicate phones have the exact same LastDate it does not work.</p>
  
  <p>Any ideas will be appreciate it.</p>
  
  <pre><code>SELECT * FROM
   (
    SELECT  ID, Phone, [LastDate]
    ,RANK() OVER (PARTITION BY Phone ORDER BY [LastDate]) AS 'RANK',                          
              COUNT(Phone) OVER (PARTITION BY  Phone) AS 'MAXCOUNT'
                FROM MyTable          
                WHERE Groupid = 5
                ) a
                WHERE [RANK] = [MAXCOUNT] 
  </code></pre>