title: How to make SQL query that outputs records that appear more than once and to include the duplicate records in the results?
body: <p>I am a new SQL programmer, and I have been trying to figure out how to write a SQL query that shows when addresses are duplicates in 4 separate attributes and outputs all of the duplicate records. I have written the following query, but it appears to only show one of the duplicate records but not all of them.</p>
  
  <pre><code>SELECT 
  apvenfil_sql.vend_no,
  apvenfil_sql.vend_name,
  apvenfil_sql.sort_name,
  apvenfil_sql.addr_1,
  apvenfil_sql.addr_2,
  apvenfil_sql.city,
  apvenfil_sql.state,
  apvenfil_sql.zip,
  apvenfil_sql.country,
  apvenfil_sql.contact,
  apvenfil_sql.acct_dt,
  apvenfil_sql.last_active_dt,
  apvenfil_sql.ap_terms_cd,
  apvenfil_sql.cus_no,
  apvenfil_sql.purch_ytd,
  apvenfil_sql.purch_last_yr,
  apvenfil_sql.amt_pd_ytd,
  apvenfil_sql.amt_pd_last_yr,
  apvenfil_sql.balance,
  apvenfil_sql.lst_chk_dt,
  apvenfil_sql.last_chk_amt,
  apvenfil_sql.chk_no,
  apvenfil_sql.payee_name,
  apvenfil_sql.A4GLIdentity,
  apaltadr_sql.vend_no,
  apaltadr_sql.vend_alt_adr_cd,
  apaltadr_sql.vend_name,
  apaltadr_sql.addr_1,
  apaltadr_sql.addr_2,
  apaltadr_sql.city,
  apaltadr_sql.state,
  apaltadr_sql.zip,
  apaltadr_sql.country,
  apaltadr_sql.A4GLIdentity
  FROM
  apvenfil_sql
  LEFT JOIN apaltadr_sql
      ON apaltadr_sql.vend_no = apvenfil_sql.vend_no 
  WHERE 
  apvenfil_sql.addr_1 IN
      (     SELECT addr_1 
            FROM apvenfil_sql
            GROUP BY addr_1
           HAVING COUNT(*) &gt; 1
      ) OR
  apvenfil_sql.addr_2 IN
      (     SELECT addr_2 
            FROM apvenfil_sql
            GROUP BY addr_2
            HAVING COUNT(*) &gt; 1
      ) OR
  apaltadr_sql.addr_1 IN 
      (     SELECT addr_1 
            FROM apaltadr_sql
            GROUP BY addr_1
            HAVING COUNT(*) &gt; 1
      ) OR
  apaltadr_sql.addr_2 IN 
      (     SELECT addr_2 
            FROM apaltadr_sql
            GROUP BY addr_2
            HAVING COUNT(*) &gt; 1
      ) 
  ORDER BY 
  apvenfil_sql.vend_no;
  </code></pre>
  
  <p>For reference, the SQL Server version is 2000.</p>
  
  <p>Thank you so much for your help!</p>