Multiple IN statements for WHERE. Would this return good data?

Posted by TheDudeAbides on Stack Overflow See other posts from Stack Overflow or by TheDudeAbides
Published on 2010-05-11T19:09:46Z Indexed on 2010/05/11 19:14 UTC
Read the original article Hit count: 343

Filed under:
|
SELECT ['VISA CK  - 021810$'].[ACCT NBR     #1], ['VISA CK  - 021810$'].[ALT CUST NM  #1], ['VISA CK  - 021810$'].[LAST USED]
FROM ['VISA CK  - 021810$']
WHERE ['VISA CK  - 021810$'].[ALT CUST NM  #1] 
    IN (
        SELECT ['VISA CK  - 021810$'].[ALT CUST NM  #1]
        FROM ['VISA CK  - 021810$']
        GROUP BY ['VISA CK  - 021810$'].[ALT CUST NM  #1]
            HAVING COUNT(['VISA CK  - 021810$'].[ALT CUST NM  #1]) > 1
        )
    AND ['VISA CK  - 021810$'].[ACCT NBR     #1]
    IN (
        SELECT ['VISA CK  - 021810$'].[ACCT NBR     #1]
        FROM ['VISA CK  - 021810$']
        GROUP BY ['VISA CK  - 021810$'].[ACCT NBR     #1]
            HAVING COUNT(['VISA CK  - 021810$'].[ACCT NBR     #1]) > 1
        )

© Stack Overflow or respective owner

Related posts about sql

Related posts about sql-server