title: SQL query to get duplicate record counts based on other factors
body: <p>I have a table (participants) which has multiple columns that could all be distinct. 
  Two columns that are of special interest in this query are the userID and the programID
  I have a two part inquery here.</p>
  
  <ol>
  <li>I want to be able to acquire the list of all userIDs that appear more than once in this table. How do I go about doing it?</li>
  <li><p>I want to be able to acquire the count of all programID's where the same userID appears in multiple programIDs. (I.E. count of programs where same userID appears in 2 programs, count of programs where same USErID appears in 3 programs, etc...)
   For Example:</p>
  
  <pre><code> programID: prog1
      userID: uid1
      userID: uid3
      userID: uid12
   programID: prog2
      userID: uid3
      userID: uid5
      userID: uid14
      userID: uid27
   programID: prog3
      userID: uid3
      userID: uid7
      userID: uid14
      userID: uid30
   programID: prog4
      userID: uid1
  </code></pre>
  
  <p>Expected Results:
       userID count = 2; programs = 3
       userID count = 3; programs = 3</p></li>
  </ol>
  
  <p>Can anyone please help me with this.</p>
  
  <p>my current code for question 1 is:</p>
  
  <pre><code>    SELECT 
      WPP.USERID, 
      WPI.EMAIL, 
      WPI.FIRSTNAME, 
      WPI.LASTNAME, 
      WPI.INSTITUTION 
      FROM WEBPROGRAMPARTICIPANTS WPP 
      INNER JOIN WEBPERSONALINFO WPI 
      ON WPP.USERID = WPI.USERID 
      INNER JOIN WEBPROGRAMS WP 
      ON WPP.PROGRAMCODE = WP.PROGRAMCODE 
      WHERE 
      WP.PROGRAMTYPE IN ('1','2','3','4','5','6', '9', '10') 
      GROUP BY 
      WPP.USERID, 
      WPI.EMAIL, 
      WPI.FIRSTNAME, 
      WPI.LASTNAME, 
      WPI.INSTITUTION 
      HAVING COUNT(WPP.USERID) &gt; 1
      ORDER BY WPI.EMAIL
  </code></pre>