title: Get values with no repeated data
body: <p>I have a query like this:</p>
  
  <pre><code>SELECT
        P.LegacyKey
        ,D.DesignNumber
        FROM tbl1 AS [SO]
   GROUP BY D.DesignNumber,P.LegacyKey
   ORDER BY LegacyKey
  </code></pre>
  
  <p>it returning values like:</p>
  
  <pre><code>+-----------+--------------+
  | LegacyKey | DesignNumber |
  +-----------+--------------+
  |     17134 |            1 |
  |     17134 |            2 |
  |     18017 |            7 |
  +-----------+--------------+
  </code></pre>
  
  <p>That I want to do is to find duplicate <code>LegacyKeys</code> and get only values who legacyKey is exist one time, so I use <code>HAVING COUNT</code>:</p>
  
  <pre><code>SELECT
        P.LegacyKey
        ,D.DesignNumber
        , COUNT([P].[LegacyKey])
        FROM tbl1 AS [SO]
   GROUP BY D.DesignNumber,P.LegacyKey
   HAVING COUNT([P].[LegacyKey])  = 1
   ORDER BY LegacyKey
  </code></pre>
  
  <p>But this is returning bad data, because it is returning LegacyKey = 17134 again and desire result is to get values where LegacyKey exists one time.</p>
  
  <p>So desire result should be only</p>
  
  <pre><code>  18017 |            7 
  </code></pre>
  
  <p>What am I doing wrong?</p>