title: GroupBy multiple columns and find duplicates
body: <p>Using c# <code>Sytem.Linq</code>here.</p>
  
  <p>I wanted to find the duplicates in my table. A duplicate is defined when the combination of three columns already exists in the table.</p>
  
  <p>For example, below is a duplicate record:</p>
  
  <pre><code>Row Id Name Value Status
   1  1  Peter 1    New
   2  1  Peter 1    Old
   3  1  Peter 1    Pending
   4  2  Peter 1    New
   5  2  Sandy 2    Old
  </code></pre>
  
  <p>In the above table Rows 1, 2 and 3 are duplicates. So I wrote the below query to find all duplicates:</p>
  
  <pre><code>//Below response holds all data from my db
  var result = response
                   .GroupBy(o =&gt; new { o.Id, o.Name, o.Value })
                   .Where(g =&gt; g.Count() &gt; 1)
                   .Select(y =&gt; y.Key)
                   .ToList();
  </code></pre>
  
  <p>My above query shows all results in the data and not duplicates. What did I do wrong here?</p>
  
  <p>I want the query to just return duplicates as per the aforementioned condition.</p>