title: SQL Server: Returning rows with multiple and distinct values
body: <p>I've been working on this issue for the last day and a half and just can't seem to find another question on here that works for my code.</p>
  
  <p>I have a table here: </p>
  
  <p>Table_D         </p>
  
  <pre><code>Policynumber|   EntryDate   |  BI_Limit   | P remium
  ------------------------------------------------------
  ABCD100001  |   5/1/16      |   15/30     | 919
  ABCD100001  |   5/13/16     |   15/30     | 1008 
  ABCD100002  |   5/24/16     |   100/300   | 1380
  ABCD100003  |   5/30/16     |   25/50     | 1452
  ABCD100003  |   6/2/16      |   25/50     | 1372
  ABCD100003  |   6/4/16      |   30/60     | 951
  ABCD100004  |   6/11/16     |   100/300   | 1038
  ABCD100005  |   6/22/16     |   100/300   | 1333
  ABCD100005  |   7/2/16      |   50/100    | 1208
  ABCD100006  |   7/10/16     |   250/500   | 1345
  ABCD100007  |   7/18/16     |   15/30     | 996
  </code></pre>
  
  <p>in which I'm trying to extract rows in which a policynumber has multiple listings <em>and</em> a different BI_Limit. So the output should be:</p>
  
  <p>Output          </p>
  
  <pre><code>Policynumber    | EntryDate  |  BI_Limit  | Premium
  ---------------------------------------------------
  ABCD100003      | 5/30/16    |  25/50     | 1452
  ABCD100003      | 6/2/16     |  25/50     | 1372
  ABCD100003      | 6/4/16     |  30/60     | 951
  ABCD100005      | 6/22/16    |  100/300   | 1333
  ABCD100005      | 7/2/16     |  50/100    | 1208
  </code></pre>
  
  <p>I'm storing Policynumber as VARCHAR(Max), EntryDate as DATE, BI_Limit as VARCHAR(Max), and Premium as INTEGER.</p>
  
  <p>The code I've want to say should work would be something along the lines of:</p>
  
  <pre><code>    SELECT * FROM Table_D
      WHERE BI_Limit IN (
          SELECT BI_Limit
          FROM Table_D
          GROUP BY BI_Limit
          HAVING COUNT(DISTINCT BI_Limit)&gt;1);
  </code></pre>
  
  <p>But this returns nothing for me. Can anyone help to show me what I'm doing wrong? Thank you.</p>