title: Finding duplicates on one column using select where in SQL Server 2008
body: <p>I am trying to select rows from a table that have duplicates in one column but also restrict the rows based on another column. It does not seem to be working correctly.</p>
  
  <pre><code>select Id,Terms from QueryData 
  where Track = 'Y' and Active = 'Y'
  group by Id,Terms
  having count(Terms) &gt; 1
  </code></pre>
  
  <p>If I remove the <code>where</code> it works fine but I need to restrict it to these rows only. </p>
  
  <pre><code>ID      Terms     Track    Active
  100     paper     Y        Y
  200     paper     Y        Y
  100     juice     Y        Y
  400     orange    N        N
  1000    apple     Y        N
  </code></pre>
  
  <p>Ideally the query should return the first 2 rows.</p>