title: Combine GROUP BY and ROW_NUMBER()
body: <p>SAMPLE DATA</p>
  
  <pre><code>userid         email_address               login_name       name                Title       org            phone_number_com
  =============  ==========================  ===============  ==================  ==========  =============  ===================
  1192           Steve.Jobs@apple.com        sjobs            Steve Jobs          CEO         Apple          N/A
  1274           Steve.Jobs@apple.com        sjobs            Steve Jobs          CFO         Apple          697-4686
  1192           Steven.jobs@apple.com       sjobs            Steven jobs         CEO         Apple          604-7126
  1885           Bill.Gates@microsoft.com    bgates           Bill Gates          CEO         Microsoft      604-7114
  1920           Bill.Gates@microsoft.com    bgates           William Gates       CTR         Microsoft      604-7247
  1951           Warren.Buffet@hp.com        wbuffet          Warren Buffet       CEO         HP             614-9141
  1954           Warren.Buffet@hp.com        wbuffet          W. Buffet           COO         HP             614-7589
  1951           Warren.Buffet@xerox.com     wbuffet          Warren S Buffet     CIO         Xerox          614-8874
  1956           Mark.Zuckerberg@fb.com      mzuck            Mark  Zuckerberg    CEO         FB             614-8295
  </code></pre>
  
  <p>QUERY</p>
  
  <pre><code>SELECT * 
  FROM
      (
          SELECT userid, name, login_name, email_address, phone_number_com,
          ROW_NUMBER() OVER(PARTITION BY [login_name] ORDER BY login_name) Num_Duplicates
          FROM web_user
      ) as Rows
  WHERE Num_Duplicates &gt; 1
  </code></pre>
  
  <p>This is my first post, hopefully I am following all the procedures. I get a result set which displays the 2nd and 3rd rows which are duplicated. I am trying to <code>GROUP BY</code> <code>login_name</code> and only display the the row with the highest <code>Num_Duplicates</code>. If a <code>login_name</code> has a <code>Num_Duplicates</code> of 2 and 3, to only display the row with 3. I hope this makes sense! Thank you in advance for any guidance you can provide. </p>
  
  <p>THESE ARE THE RESULTS I WOULD LIKE THE QUERY TO OUTPUT:</p>
  
  <pre><code>userid  | email_address | login_name    | name  | Title | org   phone_number_com    | Num_Duplicates       
  1192    | Steve.Jobs@apple.com  | sjobs | Steve Jobs    | CEO   | Apple |   N/A | 3      
  1885    | Bill.Gates@microsoft.com  | bgates    | Bill Gates    | CEO   | Microsoft | 604-7114  | 2       
  1951    | Warren.Buffet@hp.com  | wbuffet   | Warren Buffet | CEO   | HP    | 614-9149  | 3
  </code></pre>