title: Sql server : select members having 2 or more records on different date of same class
body: <p>I am trying to find out all the member ids who have more than 2 records on a different dates in the same class.</p>
  <pre class="lang-none prettyprint-override"><code>+----------+------------+-------+-----------+
  | MemberId |    Date    | Class |           |
  +----------+------------+-------+-----------+
  |   118111 | 2/18/2020  | A     | Valid     |
  |   118111 | 10/15/2020 | A     | Valid     |
  |   118216 | 1/31/2020  | B     | Valid     |
  |   118216 | 5/16/1981  | B     | Valid     |
  |   118291 | 6/9/2020   | A     | Valid     |
  |   118291 | 12/5/2020  | A     | Valid     |
  |   118533 | 4/9/2020   | A     | Not valid |
  |   118533 | 11/11/2020 | B     | Not valid |
  |   118533 | 7/22/2020  | C     | Valid     |
  |   118533 | 10/25/2020 | C     | Valid     |
  |   118293 | 3/30/2020  | A     | Not valid |
  |   118293 | 3/30/2020  | A     | Not valid |
  |   118499 | 4/16/2020  | B     | Valid     |
  |   118499 | 7/26/2020  | B     | Valid     |
  |   118499 | 3/25/2020  | A     | Not valid |
  +----------+------------+-------+-----------+
  </code></pre>
  <p>I have made a query which checks only 2 records but unable to find a solution for checking more than 2 records.</p>
  <pre class="lang-sql prettyprint-override"><code>select mc.* 
      FROM table1 AS mc
      JOIN table1 AS ma ON ma.memberid = mc.memberid
          AND ma.date != mc.date
          AND ma.class = mc.class
  </code></pre>